Laravel在不同服务器的子域中维护一个Session [英] Laravel maintain a Session in subdomain of different server
问题描述
假设在一个域( app.domain.com
)中,我设置了一个如下的会话:
Suppose in a domain (app.domain.com
) I have set a Session like this:
Session::put('test', 'value');
然后在不同的域(例如 news.domain.com
)我想检索该会话值。请注意,其他网域位于在不同服务器,但仍然是相同的域名。
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.
我的问题是,将如果我将laravel配置文件设置为
> domain => '* .domain.com'? news.domain.com
中提供Session :: get('test')
My question is, will Session::get('test')
is available in news.domain.com
if I set the laravel config file to domain => '*.domain.com'
?
推荐答案
如果子域位于不同的物理机,将 app / config / session.php
中的域设置为:
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).
这篇关于Laravel在不同服务器的子域中维护一个Session的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!