PHP session variable is retrieved in Javascript but becomes undefined
<p>I have two session variables that I retrieve in a Javascript code. This is how the code is set up:</p>

<pre><code>&lt;html&gt;
    &lt;head&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;p&gt;&lt;?php echo $_SESSION['userid'] ?&gt;&lt;/p&gt; --&gt; This works and value is shown
        &lt;p&gt;&lt;?php echo $_SESSION['accesstoken'] ?&gt;&lt;/p&gt; --&gt; Value is also shown
        &lt;script type="text/javascript"&gt;
            var userid = &lt;?php echo $_SESSION['userid'] ?&gt;;
            var token = &lt;?php echo $_SESSION['accesstoken'] ?&gt;;
            alert(userid); --&gt; this works and shows pop up with value
            alert(token); --&gt; this doesnt work and is undefined
        &lt;/script&gt;
    &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>This is the value of userid: 551234131</p>

<p>This is the value of my token:
AAADAq39fEZA0BAAVJyvfZAiu1kIcaHG4SFVzuBWl3hXfC9W0g26JaqXwZAHuNdIhh2eFDkwyopunCsZCCW3jZADT8DQBjZCAdRTC5PkgtN4wZDZD</p>

<p>Before the token value is stored in the session variable it is actually held inside another javascript variable without any problem (i.e I can call that variable with alert() and the token is shown).</p>

<p>So transfering this value FROM javascript TO session variable = no problem.
But transfering the same value FROM session variable TO Javascript = doesnt work.</p>

<p>At first I thought there was a problem with datatypes so I tried casting it to a string value but it doesnt work. Any idea on what could cause this situation?</p>
