Jump to:

22977 Posts in 11720 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » Get sessions login to work across subdomains

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

Page: 1
Go to End
Author Topic: 1090 Views
  • draft
    Avatar
    Community Member
    57 Posts

    Get sessions login to work across subdomains Link to this post

    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

  • jsantos81
    Avatar
    Community Member
    3 Posts

    Re: Get sessions login to work across subdomains Link to this post

    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

    1090 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.