Reputation: 1949
When I am setting the cookie through JSP using the below code:
String username = userinfoid;
Cookie testcoo = new Cookie ("username",username);
it is setting the cookie with value "zahidansari" (note value is with double quotes). Although value is correct it is bounded inside double quotes.
However when I am setting the cookie using the below code:
Cookie testcoo = new Cookie ("username",username);
It is setting the cookie without the quotes.
I want the cookie value to be without the quotes. Does anybody have any idea why this is happening.
Upvotes: 0
Views: 292
Reputation: 490
Just got the same problem. Not to leave this question unanswered :) this is my workaround:
Encode cookie value:
String username = userinfoid;
Cookie testcoo = new Cookie ("username", URLEncoder.encode(username, "UTF-8"));
For more information take a look other SO question
Upvotes: 1