问题
In Classic ASP, a single cookie can be a collection of name/value pairs. For instance, a cookie collection named "user" could be created to have keys which contains information about a user:
("user")("firstname")="John"
("user")("lastname")="Smith"
("user")("country")="Norway"
("user")("age")="25"
Is it possible to write that kind of cookie using Javascript, so that ASP would recognize it and parse it accordingly?
回答1:
Should be doable.
Your asp example would make a cookie that would look similar to this:
Name: user
Value: firstname=John&lastname=Smith&country=Norway&age=25
so when you set your javascript cookies it should be a similar format, try something like:
document.cookie = "user=firstname=John&lastname=Smith&country=Norway&age=25;";
来源:https://stackoverflow.com/questions/14060598/write-asp-style-cookie-with-keys-using-javascript-read-using-classic-asp