 <p>You don't need to store it in a session necessarily, it's the fact that $_SESSION is an array.</p> <p>So, what you would want would be something like this:</p> <pre><code>echo json_encode(array('sessionID' =&gt; $sessionID)); </code></pre> <p>And then when you parse the JSON with JavaScript you can access it like this:</p> <pre><code>obj = JSON.parse(jsonObj); alert(obj.sessionID); </code></pre> <p>Obviously, <code>jsonObj</code> is the JSON passed from the server.</p> <p>Hope this helps!</p>