【发布时间】:2014-01-09 19:45:11
【问题描述】:
类似的:
Multiple cookies with same name
How to handle multiple cookies with the same name?
我在我的 asp 控件的页面加载上设置了一个 cookie。我有一个函数获取 cookie 并将其存储在 var 中以供使用。我的问题是,在阅读了有关 cookie 的 msdn 站点后,我应该从 Request 还是 Response 获取 cookie,然后设置另一个的值?或者我应该从Response 获取cookie 并设置它的值?最后一个似乎不太正确,但我不知道。
MSDN 文字:
The browser is responsible for managing cookies on a user system. Cookies are sent to the browser via the HttpResponse object that exposes a collection called Cookies. You can access the HttpResponse object as the Response property of your Page class. Any cookies that you want to send to the browser must be added to this collection. When creating a cookie, you specify a Name and Value. Each cookie must have a unique name so that it can be identified later when reading it from the browser. Because cookies are stored by name, naming two cookies the same will cause one to be overwritten.
我假设我应该从request 获取它并设置response cookie,这似乎不太正确,因为我最终得到了具有不同值的双cookie。我担心的cookie是TRACKINGINFO。它设置在不同的子域上,我需要获取值并添加到它并重新设置值。
这是来自 Google Chrome 的请求标头:
ASP.NET_SessionId=bi2ingjjk5f4nhm; referer_domain=dev-znode.local; referer_query=; TRACKINGINFO=1234%2C526%2C1234%2C526; __utma=251778844.1427755012.1389292549.1389292549.1389292549.1; __utmb=251778844.16.10.1389292549; __utmc=251778844; __utmz=251778844.1389292549.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); ZNodeCookie; LocaleID=43; TRACKINGINFO=1234%2C526%2C1234%2C526,2508
请求标头:
TRACKINGINFO=1234%2C526%2C1234%2C526,2500; expires=Fri, 10-Jan-2014 19:21:53 GMT; path=/
【问题讨论】:
-
您的问题与您链接的两个问题有何不同?