| public String[] getUsernameAndTokenFromCookies(HttpServletRequest request){ |
| String[] usernameAndToken = new String[2]; |
| |
| Cookie[] cookies = request.getCookies(); |
| String usernameInCookie = null; |
| String tokenInCookie = null; |
| |
| if( cookies != null ){ |
| for (int i = 0; i < cookies.length; i++){ |
| Cookie cookie = cookies[i]; |
| if (cookie.getName().equals("username")){ |
| usernameInCookie = cookie.getValue(); |
| } |
| if (cookie.getName().equals("token")){ |
| tokenInCookie = cookie.getValue(); |
| } |
| } |
| } |
| |
| usernameAndToken[0] = usernameInCookie; |
| usernameAndToken[1] = tokenInCookie; |
| |
| return usernameAndToken; |
| } |