Sometimes $cookies.set is not consistent with `document.cookie=`
See original GitHub issueIssue Description
When we use document.cookie='email=lifubang@acmcoder.com'
, the value of document.cookie
is email=lifubang@acmcoder.com
;
But when we use this.$cookies.set('email', 'lifubang@acmcoder.com')
, the value of document.cookie
is email=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.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Why would setting document.cookie not work in Chrome?
The way cookies work, at least in Chrome, is a bit weird. If you need to change a cookie's value, then you need...
Read more >Document.cookie - Web APIs | MDN
The Document property cookie lets you read and write cookies associated with the document. It serves as a getter and setter for the...
Read more >Cookies, document.cookie - The Modern JavaScript Tutorial
A write operation to document.cookie updates only cookies mentioned in it, but doesn't touch other cookies. For instance, this call sets a ...
Read more >setcookie - Manual - PHP
It seems the IE (6, 7, 8 and 9) do not accept the part 'Expire=0' when setting a session cookie. To fix it...
Read more >Upcoming changes in cookie handling in Google Chrome
If your application is used in cross-site scenarios and it sets cookies using the platform's JavaScript extensibility (i.e. you're setting ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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. When I use Vue.$cookies.get() it returns the escaped strings for me, so the functionality is ruined.
My understanding is that the cookie stores a standard string and handles all required escaping itself as well.
当cookie含有 ASCII 特殊符号时,encodeURIComponent会对key or value 进行编码,这样会导致接下来的请求后端cookies校验无法通过,希望不要对@&=+$#这些特殊符号进行编译。