ryanh_106 Posted January 10, 2007 Share Posted January 10, 2007 Hey,I want people to be able to log into my forum (which is stored on a sub-domain) and then switch over to the main website and still be recognised. However as sessions are only active while you remain on the same domain, I cant get this to work. Surely there must be some way to set for which domains the session is active. Any ideas? Any suggestions are much appreciatedRyan Quote Link to comment https://forums.phpfreaks.com/topic/33531-sessions-across-domains/ Share on other sites More sharing options...
trq Posted January 10, 2007 Share Posted January 10, 2007 The easiest way is to save your session data into a database allong with the session id and an ip. Then, pass the session id via the url to the second domain, from here, use the id to pull the infomation back out of the database and into a new session specific to that domain. Quote Link to comment https://forums.phpfreaks.com/topic/33531-sessions-across-domains/#findComment-156927 Share on other sites More sharing options...
Ninjakreborn Posted January 10, 2007 Share Posted January 10, 2007 Well for a cookie, you can set it cross domain. So you can set the sessions up, but also pass a specific cookie id over to it, with a generated id code, and use that id code to retrieve the data from the database, but thorpe's sounds more promising. Quote Link to comment https://forums.phpfreaks.com/topic/33531-sessions-across-domains/#findComment-156951 Share on other sites More sharing options...
trq Posted January 10, 2007 Share Posted January 10, 2007 You might also take a look at [url=http://www.php.net/manual/en/function.session-set-cookie-params.php]session_set_cookie_params[/url]() and its related docs. Probably a better solution amongst them. Quote Link to comment https://forums.phpfreaks.com/topic/33531-sessions-across-domains/#findComment-156962 Share on other sites More sharing options...
ryanh_106 Posted January 10, 2007 Author Share Posted January 10, 2007 Hmmm, I thought it was going to involve something like that, kinda defies the point of redirecting to the forum login page at all I may as well just work out exactly what the forum does to log someone in, and duplicate it on my site. But then, when they move over to the forums, they wont be logged in...... damnit this is going to take more thought than i can manage so early in the day!Thanks for the advise guys Quote Link to comment https://forums.phpfreaks.com/topic/33531-sessions-across-domains/#findComment-157287 Share on other sites More sharing options...
trq Posted January 10, 2007 Share Posted January 10, 2007 Ive never needed to use it but, from glancing the manual it looks like [url=http://php.net/session_set_cookie_params]session_set_cookie_params[/url] will allow you to set what domains your session cookie can be read from. Quote Link to comment https://forums.phpfreaks.com/topic/33531-sessions-across-domains/#findComment-157293 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.