This ancient post from 2008 is still quite popular and really shouldn’t be, as this approach has security issues:
- The session ID is exposed in the POST request.
- The receiving page accepts the session ID without additional validation that it belongs to a legitimate session initiated by the same user.
Original post below.
The problem: Multiple domains hosted on one server needed access to the user’s session data. In my case, various shopping domains were sharing one (SSL-enabled) domain where the users could place their orders.
The solution I found was surprisingly simple: Since these domains were hosted on the same server and used the same session save path, I was wondering if I could simply pass the existing session ID along to the new domain in order to give it access to the corresponding session file. Indeed all it took was a hidden form field containing the session ID and something like “session_id($_POST[‘SID’])” on top of the first page of the ssl-domain (before session_start()). Voilà, the old session ID was also the new one and the ssl-domain could continue working with the session data. Continue reading Sharing session data across domains with PHP