-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sometimes $cookies.set is not consistent with document.cookie=
#66
Comments
document.cookie=
document.cookie=
The cookie value string can use encodeURIComponent() to ensure that the string does not contain any commas, semicolons, or whitespace (which are disallowed in cookie values). encodeURIComponent/decodeURIComponent escape sequences (e.g. comma, quotes, [], : , ; etc) back-end transcoding Java Example:
PHP Example:
|
I think the operation
Yes, back-end can decode it correctly. My thought is that we should not force the back-end to change the code when I use |
I agree with @lifubang in that I am having issues with this as well. I don't mind if the value is encoded in the cookie storage, but the decode does not work for me when I get cookies back. My understanding is that the cookie stores a standard string and handles all required escaping itself as well. |
Yes, we may hit this issues when we read the cookie created by the back-end. |
当cookie含有 ASCII 特殊符号时,encodeURIComponent会对key or value 进行编码,这样会导致接下来的请求后端cookies校验无法通过,希望不要对@&=+$#这些特殊符号进行编译。 |
When we use
document.cookie='email=lifubang@acmcoder.com'
, the value ofdocument.cookie
isemail=lifubang@acmcoder.com
;But when we use
this.$cookies.set('email', 'lifubang@acmcoder.com')
, the value ofdocument.cookie
isemail=lifubang%40acmcoder.com
.It's ok when we just use cookie in front-end, but the back-end will get an inconsistent cookie value when we use vue-cookies to replace
document.cookie=
in front-end, it would cause the back-end to upgrade their code.The text was updated successfully, but these errors were encountered: