Passing a PHP variable to another page via jQuery
<p>EDIT: I can put the question in a shorter way that perhaps focuses more closely on the real problem:</p>

<p>Is there a way to keep PHP Sockets alive over multiple pages? That is, can I store the connection (the socket object) in any way?</p>

<p>I want to save a socket connection between two PHP pages where the other page is loaded via jQuery ajax. I tried it with sessions and so far got this on my main page:</p>

<pre><code>$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$res = socket_connect($sock, $host, $port);
session_start();
$_SESSION['sock'] = $sock;  
</code></pre>

<p>I then load a page with jQuery:</p>

<pre><code>$("#" + in_name + "_holder").load("set_setpoint.php", {name:in_name, value:in_value});
</code></pre>

<p>And in set_setpoints.php:</p>

<pre><code>session_start();     
require_once("sock_funcs.php");    
echo $_SESSION['sock'];
</code></pre>

<p>I only get '0', but what I should get is something like "Resource id #xxx". Maybe sessions is the wrong way?</p>
