I have done quite some researches on the topic, most answers I got is that cookie will NOT work on localhost since cookie expects the domain to contain at least 2 dots. But my question is, since ASP.NET WebSecurity class is able to set the authentication cookie from the server side, and javascript is able to set the cookie on client side when I am using localhost as domain. So there must be a way to do it, I would like to know how could it be done from the server side.
Update: Currently I am trying to do it with Java server.
Cookie tokenCookie = new Cookie("Token", token);
/*
will work if I include this line and use 127.0.0.1 to access my page
userNameCookie.setDomain("127.0.0.1");
*/
tokenCookie.setPath("/");
response.addCookie(tokenCookie);
return Response.ok().build();
I have no idea why there are two people trying to close this question as a duplicate. Please read people, I said I KNOW the reason why the cookie is not being set, but I know I could certainly do it and I want to know how!!!