title: JavaScript Not Sending Info To WebSocket When Page is Loaded
body: <p>I am having trouble sending information of a session cookie when loading a page.</p>
  
  <p>Here is how the function executes</p>
  
  <pre><code>&lt;body onload="example();"&gt;
  </code></pre>
  
  <p>Here is the function it self</p>
  
  <pre><code>function example() {
    websocket.send("&lt;?php print($_SESSION['example']) ?&gt;")
  }
  </code></pre>
  
  <p>I've tried this way as well, but still does not work.</p>
  
  <pre><code>function example() {
    websocket.send("Test")
  }
  </code></pre>
  
  <p>I also tried calling this function when a button is clicked and it does work.</p>
  
  <p>I was thinking maybe the connection to the websocket is not fast enough and the <code>example();</code> function is called before the connection is established. Please let me know how I can make this work.</p>