简体   繁体   English

跨子域的Laravel会话

[英]Laravel session across subdomains

I have a marketing application that is on the main domain (www.example.com ), and an admin application that is on the subdomain(accounts.example.com ). 我有一个在主域(www.example.com)上的市场营销应用程序,以及在子域(accounts.example.com)上的一个管理应用程序。 A user would visit www.example.com , register/login and gets redirected to accounts.example.com. 用户将访问www.example.com,进行注册/登录并被重定向到account.example.com。 My problem is that my session cookie from www.example.com is being overwritten when a user is redirected to accounts.example.com. 我的问题是,当用户重定向到account.example.com时,我来自www.example.com的会话cookie被覆盖了。

Both applications are using the same session cookie, but the accounts application always overwrites it. 两个应用程序都使用相同的会话cookie,但是帐户应用程序始终会覆盖它。 My data that was set for the session is no longer available after being redirected to the subdomain (unavailable in both domains). 在会话中设置的我的数据在重定向到子域后不再可用(在两个域中均不可用)。 Anyone have an idea how I can approach this problem? 有人知道我该如何解决这个问题? Thank you! 谢谢!

Web servers usually do not permit session data to be shared across domains, or even sub domains. Web服务器通常不允许跨域甚至是子域共享会话数据。 For that purpose, you must store the session data in a place where it can be reached across domains... eg a database. 为此,必须将会话数据存储在跨域(例如数据库)可以访问的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM