Getting PHP session array values into Javascript
<p>I have stored array values in PHP session.</p>

<p>Now I want to retreive this array and convert it to javascript aray.</p>

<p>This is how I set PHP session:</p>

<pre><code>var listone = ["one", "two", "three"];

function setSession(listone){
    $.get(
        "setSession.php",
        {listone:listone} 
    );
}
</code></pre>

<p>So if once these values are set and I refresh the page, I check if the session has been set. If set, I want to do something like this:</p>

<pre><code>&lt;?php
session_start();
if(isset($_SESSION['listone']))
{
?&gt;
  listone = Array('&lt;?php echo json_encode($_SESSION['listone']) ?&gt;');
&lt;?php
}
?&gt;
</code></pre>

<p>When I do this, the 'listone' array is showing me like this:</p>

<pre><code>listone[0] = [
listone[1] = "
listone[2] = o
listone[3] = n
listone[4] = e
listone[5] = "
.... etc
</code></pre>

<p>I know I am doing something wrong.
Is it the way I am storing the array in PHP session?
or
Is it the way I am retrieving it back to JS?</p>

<p>Thanks for any pointers. I am willing to dig more if guided properly :)</p>
