Laravel maintain a Session in subdomain of differe

2019-02-09 12:42发布

Suppose in a domain (app.domain.com) I have set a Session like this:

Session::put('test', 'value');

Then in different domain (ex. news.domain.com) I want to retrieve that session value. Note that the other domain is located ON DIFFERENT SERVER, but still same domain name.

My question is, will Session::get('test') is available in news.domain.com if I set the laravel config file to domain => '*.domain.com'?

1条回答
Deceive 欺骗
2楼-- · 2019-02-09 13:38

If you have the subdomains hosted on different physical machines, setting the domain in app/config/session.php to this:

'domain' => '.domain.com'

will work as long as the two apps will be able to access a shared session data storage (for example using the database session driver and having a common database that stores the sessions).

查看更多
登录 后发表回答