Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel maintain a Session in subdomain of different server

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'?

like image 685
user2002495 Avatar asked Oct 20 '14 10:10

user2002495


1 Answers

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).

like image 86
Bogdan Avatar answered Oct 17 '22 01:10

Bogdan