在两次登录中使用相同的 cookie

发布于 2024-09-03 02:58:28 字数 339 浏览 3 评论 0原文

我需要你的帮助

我有一个使用 Jquery 的 MVC 项目,我在其中实现了一种使用 cookie 来保存、清除和检索登录名和密码的“记住我”机制。

我还有两个屏幕供用户登录。我希望两个登录操作相同的 cookie。我必须实现它,但我意识到每个人都有不同的行为。我的意思是,我在第一次登录时保存的 cookie 值与检索第二次登录时(当我打开它时)的值不同。换句话说,如果我在第一次登录时标记“提醒我”,则不会反映在第二次登录上,反之亦然。我该怎么做才能让它们都操作并从同一个 cookie 读取相同的值?是否可以?

PS:对于这种情况,我使用相同的网络导航器:Firefox 或 IE。

提前致谢

I need your help

I've a MVC project that uses Jquery, where I've implemented a mechanism of "Remember Me" using cookies to save, clear and retrieve the login and password.

I also have two screens where the user does the login. I want that both logins manipulate the same cookie. I've got to implement it, but I've realized that each one has a different behaviour. I mean, the cookie's value I save in the first login is not the same than the value that retrieves the second login (when I open it). In other words, if I mark "remind me" on the first login, it isn't reflected on the second login and viceversa. What can I do to make that both of them manipulate and read the same values from the same cookie? Is it possible?

PS: For this situations I'm using the same web navigator: Firefox or IE.

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

绾颜 2024-09-10 02:58:28

Cookie 特定于创建它们的域。如果您有两个登录屏幕,则需要将它们放在同一个域下(如果您有多个域,则需要将它们放在同一个域下,例如login.yourdomain.com

Cookies are specific to the domain that creates them. If you are having two login screens,you need to have them under the same domain ( some thing like login.yourdomain.com if you have more than one domain)

Sri

吾性傲以野 2024-09-10 02:58:28

如果您使用 formsauthentication,则可以更改 cookie 域。
如果没有,您也应该能够更改它。

只需为两个站点使用相同的域名即可。

http://msdn.microsoft.com/en -us/library/system.web.security.formsauthentication.cookiedomain.aspx

hth

you can change the cookie domain, if you are using formsauthentication.
if not, you should also be able to change it.

just take the same domain name for both sites.

http://msdn.microsoft.com/en-us/library/system.web.security.formsauthentication.cookiedomain.aspx

hth

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文