Write ASP-style cookie (with keys) using Javascript; read using classic ASP

有些话、适合烂在心里 提交于 2019-12-10 09:42:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!