I was trying to set up cookies in JavaScript, when I encountered a seemingly weird problem.
I just wanted to store some information in a cookie for later use (testing purposes only). All I did was execute this line:
window.cookie = "token=" + value + "; expires=" + date + ";";
If I execute window.cookie afterwards however the result is as follows:
"Cookie: token=value"
I would expect the result to be: "Cookie: token=value; expires=date;
It just erases everything after the semicolon in the string. If I change them to commas instead everything gets concatenated correctly. So there has to be some problem with semicolons? But in every "tutorial" for cookies they have written stuff like that. I tried many things like encoding semicolon values and what not. Im sure there is a simple answer to this?
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire