[英]Two cookies with the same name but slightly different domain name? How do i access them with JS
So there are two cookies, one under "www.mywebsite.com" and the other under "mywebsite.com" so after some testing i managed to figure out the latter is for logins to my site and the former is just like, whenever anyone visits the site I think (or something along those lines, I don't know the specifics.所以有两个 cookies,一个在“www.mywebsite.com”下,另一个在“mywebsite.com”下,所以经过一些测试后,我设法弄清楚后者是用于登录我的网站,而前者就像任何人一样访问我认为的网站(或类似的东西,我不知道具体情况。
At any rate, they are both named xxxx, and when I try to access them I am given the one from www.mywebsite.com and I need the other one, how can I change which cookie is accessed in javascript/jquery?无论如何,它们都被命名为 xxxx,当我尝试访问它们时,我从 www.mywebsite.com 获得了一个,而我需要另一个,如何更改在 javascript/jquery 中访问的 cookie?
If the cookie is written to a specific subdomain, then that cookie can only be accessed by that particular subdomain.如果 cookie 被写入特定的子域,则该 cookie 只能由该特定子域访问。
Cookies set for .mywebsite.com
can be accessible at www.mywebsite.com
, but not vice versa. Cookies 设置为.mywebsite.com
可以在www.mywebsite.com
访问,但反之则不行。
since www
is a subdomain you need to be on that subdomain to access that cookie.由于www
是一个子域,因此您需要在该子域上才能访问该 cookie。 So it seems your cookies as subdomain based.因此,您的 cookies 似乎是基于子域的。
if you want the non-subdomain one you need to move your document location to mywebsite.com without that subdomain.如果您想要非子域,则需要将文档位置移动到没有该子域的 mywebsite.com。
and you'll better use global cookies next time and make their names unique下次你最好使用全局 cookies 并使其名称独一无二
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.