Control character in cookie value, consider BASE64 encoding your value, java operation cookie will report an error in Chinese, the report will report
The project uses cookies to save Chinese characters, but the following error is reported:
Control character in cookie value, consider BASE64 encoding your value
It indicates that the value saved to the cookie has a control character and cannot be saved. But in fact the data does not have this problem. Looking at the following sentence, it seems that the value to be saved is base64 encoded. It may be because of garbled Characters During Chinese encoding, which may lead to some control characters. It seems that the setCookie method does not support saving the Chinese (GBK) encoding format.
Solution: encode the value to be saved using URLEncoder. encode (value, "UTF-8.
Decoding is also performed during extraction:
URLDecoder. decode (c. getValue (), "UTF-8 ");
PS. the same Code, I did not report an error in another project, check found that my another project database Save the format is UTF-8, so take it out can be used directly, the error is returned in GBK encoding. It seems that in JAVA Development, if you can use UTF-8 or use UTF-8 is better, must use Chinese (GBK), please be careful about Chinese garbled encoding problem.
Experience: Do not use GBK Chinese format for UTG-8 encoding. Do not save data in English.
Website login Error Control character in cookie value, consider BASE64 encoding your value
Encoding
To solve the base64 problem, go to GOOGLE search and find out --
Why is it easy to enter English --
Base64 encoding is not required for English