title: Pass value from php to javascript
body: <p>Hello Im trying to pass value stored in php to javascript code.</p>
  
  <p>I try to pass the value in <code>$_SESSION[user]</code></p>
  
  <p>If I have this script in my header:</p>
  
  <pre><code>&lt;script&gt;
  
  var user = ? //How to pass the value?
  
  &lt;/script&gt;
  </code></pre>
  
  <p>In my buttons I do something like this:</p>
  
  <pre><code>onclick="foo('&lt;?php session_start(); echo $_SESSION[user];?&gt;')
  </code></pre>
  
  <p>But how do I pass it without the user click?</p>
  
  <p>Thanks for helping</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>My JS function located in other file and I reference them by this code in my header:</p>
  
  <pre><code>&lt;script src="class_functions"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>How do I pass the same parameter to the other file?</p>