So I am working with Angular, Java servlet and postgresql trying to build a little login system. I would like to use cookie to store the user name and user password.
String username = request.getParameter("name");
String password = request.getParameter("password");
if(LoginInfoDAO.verifyuser(username, password)){
String.valueOf(UserDAO.getUserByUsername(username).getUser_id()));
Cookie c1 = new Cookie("userid",String.valueOf(UserDAO.getUserByUsername(username).getUser_id()));
c1.setMaxAge(20);
c1.setPath("/");
c1.setDomain("localhost");
response.addCookie(c1);
PrintWriter out = response.getWriter();
out.print(UserService.getUserJson(username));
}
else {
response.setStatus(404);
}
I was able to add the cookie and retrieve the stored data on the other servlet on the windows postman app but not in chrome nor the postman chrome extension.
Cookie c[] = request.getCookies();
int userid = Integer.parseInt(c[1].getValue());
out.print(om.writeValueAsString(ReimbService.getTicketsByUserid(userid)));
please help, this is so weird