title: How to reach php $_SESSION array in javascript?
body: <p>I am trying to build some javascript function and I need to check if the users are logged in or not. When a user log in to my site I set a variable in session array named is_logged. I want to reach that variable in javascript is it possible???
  I tried some ways but did not work like following:</p>
  
  <pre><code>var session = "&lt;?php print_r $_SESSION['is_logged']; ?&gt;";
  alert(session);
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>var session = '&lt;?php echo json_encode($_SESSION['is_logged']) ?&gt;';
  alert(session);
  </code></pre>
  
  <p>It is either show a text or never alert at all</p>