View Full Version : Sharing session data on different sites?

04-03-2007, 09:24 PM
Hi there,

I have multiple websites, and i want to enable it so that when a user goes to any of the websites, and logges in, it will automatically share the same session id throughout all my sites so that they are logged in on all sites.

Is there a way to do this?

04-03-2007, 09:27 PM
If the websites are all on the same server AND are using or have access to the same database (specifically the users/sessions table) then yes.

Well for subdomains I know its possible as I do it. I have never done it with different domain names. You may run into a problem with assigning the session/cookie to the domain. Not sure.

04-03-2007, 09:47 PM
Yes, the websites are on the same server, and yes they both have access to the same database.

04-03-2007, 10:09 PM
Then have a gander at this page:


You will have to do your own saving/loading from the database, but that way you can hook it up to several sites.

04-03-2007, 10:15 PM

But when it says...

function open($save_path, $session_name)
global $sess_save_path;

Does the $save_path variable refer to opening it from a mysql database? Or a users cache?

And what will been to be put for the session name?

04-03-2007, 10:27 PM
You will have to figure that out from the page I linked you too.

Since I haven't ever set this up.

Why not try a test page. Echo out each function and its variables. See what it is giving you.

04-04-2007, 11:50 PM
Ok, got it all sorted now. :)

04-04-2007, 11:52 PM

04-05-2007, 09:30 PM
Basically, when a person logges in, it sends a form to another website of mine with the session data, then diverts back. So they are logged in on both sites!

04-05-2007, 09:33 PM
Yea but is it sharing the same session id?

04-05-2007, 10:11 PM
That sounds like a kludge.