treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Pass php sessions to subdomains

  • I have found a couple of answers, some need cookies some don't. I don't want cookies. Also the other answers needed access to the php.ini which in my case and many others is restricted. So I'm just wondering: Is there any way I can pass php sessions (php_session()) over subdomains without using cookies OR php.ini? I honestly don't think so, but if there is please comment below

    Thank you.
    - Schart
  • Even setting a cookie wouldn't work unless you modified the php.ini file as security measures built into browsers and the PHP core forbid the access of both sessions and cookies that aren't the same domain as the origin, one thing people are suggesting which i think is risky is saving the session to a database which both domains have access to and redirect the user with a session id as part of the query string in the URL and update the session_id on the new domain.

    Personally i feel there is a lot of room for things to go wrong doing it that way so i wouldn't recommend even trying it but it's up to you whether you want to or not, apart from that editing your php.ini file is the most assured way to go about doing this.
  • Hmm.. Okay. I could see one way going OK though, maybe passing a form submission as a "link" to the subdomain, giving it information. This would only work from that "link" though.