title: Transfer session across server in PHP
body: <p>I need to transfer the user session across servers. ie. If user logged in server1 and if the user exists in server2 , then I have to transfer the user session details to server2. For this I used the following technique</p>
  
  <p>From server1, redirect user to <a href="http://server2/auth_from_server1.php?sessionid=12345">http://server2/auth_from_server1.php?sessionid=12345</a>
  On server2 (internally, in the PHP code of auth_from_server1.php), do a request to <a href="http://server1/secret/check_session_id.php">http://server1/secret/check_session_id.php</a> with the sessionid, 12345.
  On server1, in the implementation of check_session_id.php, validate the ID and return OK, FAILURE, and session related data you want to pass, such as username, ...
  On server2, when the call returns with OK, store the transferred session data, and give the user a cookie and session for this server.</p>
  
  <p>But when the call back function call the auth_from_server1.php the value in session id is null. I tryed to check the sessionid as</p>
  
  <pre><code>if(isset($_SESSION['sessionId']))
  echo 'true';
  else
  echo 'false';
  </code></pre>
  
  <p>But $_SESSION['sessionId'] is null. In login page I am setting the value for session id as </p>
  
  <pre><code>$_SESSION['sessionId'] = session_id();
  </code></pre>
  
  <p>Thanks in advance....</p>