I have set a cookie to an email address for a low level login. When i get the value of the cookie it does not return anything past the @ sign?
For example :
cookie value = 'name@domain.com'
cookie get value = 'variable = cookies[loop].getValue()'
Returns = 'name'
Any ideas on how 开发者_JAVA百科to solve this?
Possibly escape the characters?
The @
is an invalid character in a cookie. I suggest to URL-encode and URL-decode the cookie value.
Cookie cookie = new Cookie(name, URLEncoder.encode(value, "UTF-8"));
// ...
and
String value = URLDecoder.decode(cookie.getValue(), "UTF-8");
// ...
Declaration of cookie
enter code here
String str="name@domain.com";
str=URLEncoder.encode(str);
Cookie ck2=new Cookie("email",str);
===============================================================
String a = URLDecoder.decode(cks[i].getValue());
this will get you cookie all characters including @, after@
精彩评论