Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Get sessions login to work across subdomains


Reply

2 Posts   1186 Views

Avatar
draft

1 November 2009 at 6:00pm Community Member, 57 Posts

Hi,

I need to know how to get silverstripe login session so it can work across subdomains.

For example if i logged in to : www.website.com, i need it still to be logged in when i change the url to subdomain.website.com

What i have tried is :

Add this line on sapphire/main.php :

ini_set ("session.cookie_domain", ".website.com");
Session::start();

But it's not working, even the Security/login is become not working(seem like no session created), please help with this, any help would be appreciated.

Thx

Avatar
jsantos81

20 May 2011 at 11:10pm Community Member, 3 Posts

In order to set the session.cookie_domain, you should use the set_cookie_domain static method from Session class.

Example:
Session::set_cookie_domain(".website.com");

I put this in _config.php to avoid call this method in multiple pages (site entry points).

And, you should also remove the Session::start() from your code below since it is not needed.

JSantos