Cannot get php session variable to set a var in javascript
<p>I have a session variable called <code>$_SESSION['SESS_USER_TYPE']</code> in my php file which is set to a 2 character string. The php script redirects to an HTML file where I want to get the php session variable into a javascript variable.</p>

<p>I am using it in my javascript as follows, but I get nothing in the javascript variable.</p>

<pre><code>var user_type = &lt;?php echo $_SESSION['SESS_USER_TYPE']; ?&gt;; 
</code></pre>

<p>This does not work.</p>

<p>Further to input received from other users, I tried the following :</p>

<pre><code>var user_type = '&lt;?php echo json_encode($_SESSION['SESS_USER_TYPE']) ?&gt;';
</code></pre>

<p>Javascript returns a syntax error to the above.</p>

<p>I then tried</p>

<pre><code>user_type = "&lt;?php echo json_encode($_SESSION['SESS_USER_TYPE']) ?&gt;";
</code></pre>

<p>This does not give an error in Javascript. However it returns the following value to user_type which is :</p>

<pre><code>&lt;?php echo json_encode($_SESSION['SESS_USER_TYPE']) ?&gt;

$_SESSION['SESS_USER_TYPE'] is set to the string 'WO'.
</code></pre>
