How is my session variable defined on a remote page? Just curious for background knowledge
<p>Hey guys, one more quick question for any experts out there. I have a form that is submitted via jquery ajax, works perfectly (I tested), and uses a form token (I set a session variable and pass through form and check that the token is equal to the posted token to prevent csrf attacks, see below...). My question is that I defined my session variable on the form page and used php session_start() on the validation page, but I am not sure how $_SESSION['token'] is still defined if I am not actually posting to that page or physically accessing that page with my browser (I am sending an ajax call). How $_SESSION['token'] be defined on a remote page?</p>

<p>Ex. set variable</p>

<pre><code>if (!isset($_SESSION['token']) and $session-&gt;logged_in)
{
$_SESSION['token'] = md5(uniqid(rand(), TRUE));
}
$token =$_SESSION['token'];
</code></pre>

<p>pass token through form in hidden input, then check</p>

<pre><code>if ($_POST['token'] == $_SESSION['token']){
</code></pre>
