Page 1 of 1

Transfering session data between servers

Posted: Wed Dec 29, 2004 10:59 am
by DudeBori82
In the process of navigating through my site, the user travels between two servers. As they navigate, session arrays store the data I need, but it's lost when they go to the new server. What is the best way to "copy" or "transfer" data to a new session on the other server. Or possibly transfer the session between servers. (The data is stored in arrays, so using POST method is difficult and tedious.)

Posted: Wed Dec 29, 2004 11:27 am
by feyd
a ghetto way is to transfer the data behind the scenes.. either posting it (recommend encryption) using one of the request functions, or through the database (ideal) if the database is accessible between the servers. However, the session id may be a pain to transfer, if they truly are different domains...

Posted: Wed Dec 29, 2004 1:27 pm
by rehfeld
it shouldnt be difficult to post the data to the other server at all if you use the right methods.


$data = serialize($_SESSION);

now post $data to the other server


you wil need to restore the data like

$_SESSION = unserialize($_POST['data']);

you may need to use stripslashes if magic quotes is on.

and like feyd said, encrypt it.