title: How to use PHP session variable in Javascript?
body: <p>I have a .php file and .js file. I want to use the <code>php</code> variable in <code>javascript</code> file but its not working. I found a solution by using session but that didn't worked.Can anybody provide me a solution or have a look at the code if there is any mistake.</p>
  
  <p>In .php</p>
  
  <pre><code> $wd=500/$w;
   $_SESSION['wd']=$wd;
  </code></pre>
  
  <p>In .js</p>
  
  <pre><code>  var sf= &lt;?php echo json_encode($_SESSION['wd']);?&gt;; 
  </code></pre>