PDA

View Full Version : can session variables be passed between two different servers?


chleng
10-13-2005, 03:46 AM
Hi,

can session variables be passed between two different servers?

I have on page1.php on server1


<?session_start();
$_SESSION['User'] = 'chleng';
?>

<a href="cdr.chleng.com/voip_user_menu.php" target="_self">
cdr detail
</a>



have on page2.php on server2



session_start()

if ( !isset($_SESSION['User']))
{

echo "<BR>";
echo "<BR>";
echo "<center><font color='#993300' size='4' face='Arial, Helvetica, sans-serif'>Login Incorrect.</font></center>";
echo "<BR>";
echo "<center><FORM METHOD=POST ACTION='$login_page'><INPUT TYPE='submit' VALUE='Click here to login page'></FORM><center>";
}


thanks

jon.php
10-13-2005, 05:13 AM
no it won't

Ökii
10-13-2005, 09:23 AM
As jon says, sesssion data cannot be passed between servers:

Basically, all the session data (such as var = val, var2 = val2) is stored on the server in a text file with a unique name (generally a prefix_ plus a 32 char hex string and normally in /tmp folder).

A cookie is sent with the page request (upon session_start() - which thusly has to be before any output due to the headers) holding a value that references that unique filename.

Upon the next request, the cookie is sent back and the server interprets the value (again upon session_start) and tries to find a file with that unique filename. If it finds one it evaluates the session data so you can use it within the script.

As such, the data is not available for another server to use - and *generally* two sites on a server cannot use the same session data as the cookies will be locked to the one domain.

marek_mar
10-13-2005, 03:05 PM
The new Zend Platform is supposed to be able to do this... if you wan't to pay for it.