title: How can I carry a socket connection through multiple web pages?
body: <p>I am using node.js and socket.io for some two way data handling. What I want is persistent connections when the client navigates through the site.
  I was using standard </p>
  
  <pre><code>var socket;
  socket = io.connect("http://localhost:port");
  socket.on('connect', function(data){
      console.log("called connect");
      console.log(user_id);
      socket.emit('init', user_id);
  });
  </code></pre>
  
  <p>This way I assign the user_id to that socket and can use that later to send data selectively to certain users.
  I was first inserting this in every web page.
  I notice that socket connect and disconnect is called when we move to new page and even on reloads. Is there a way to avoid this and do the <code>init</code> call only once?</p>
  
  <p>I tried looking at <code>express.js</code> but couldn't figure out any obvious solutions.</p>