Location: PHPKode > scripts > sessionSharing > sessionsharing/sessionShare.php
<?php
//########################################################################################
// -------------- Summary
// Share session vars over multiple servers. All session vars of one server can be transmited to another server.
// Example : You have a cart on a nonsecure server, and you want to transmit data to another server, secure.
//
// -------------- Author
// Logan Dugenoux - 2003
// hide@address.com
// http://www.peous.com/logan/
//
// -------------- License
// GPL
//
// -------------- Methods :
// - createTransmitString() 
// - readTransmitString()
//
// ------------- Example :
// In first page (nonsecure)
// $sh = new sessionShare();
// echo "<a href=http://secure.peous.com/otherpage.php?".$sh->createTransmitString().">Go to secure site</a>";
// 
// In second server :
// $sh = new sessionShare();
// $sh->readTransmitString();	// session vars are restored !
//
// Have fun !!!
//
//########################################################################################

	class sessionShare
	{
		function sessionShare() 
   		{
   		}
   		
   		function createTransmitString() 
   		{
   			global $HTTP_SESSION_VARS;
   			$str =  "";
   			$i = 1;
   			foreach( $HTTP_SESSION_VARS as $k => $v )
   			{
   				$str .= "&sn".$i."=".base64_encode($k)."&sv".$i."=".base64_encode(serialize($v));
   				$i++;
   			}
   			return $str;
   		}
   		
   		function readTransmitString() 
   		{
   			global $HTTP_SESSION_VARS;
   			global $HTTP_GET_VARS;
   			$i =  1;
   			while (1)
   			{
   				if (isset($HTTP_GET_VARS["sn".$i]))
   				{
   					$HTTP_SESSION_VARS[ base64_decode($HTTP_GET_VARS["sn".$i]) ] = unserialize(base64_decode($HTTP_GET_VARS["sv".$i]));
   				}
   				else
   				{
   					break;
   				}
   				$i++;
   			}
   			return $str;
   		}
	}
?>
Return current item: sessionSharing