title: Node.js TCP socket sessions
body: <p>I have multiple clients connecting to a Node.js TCP socket server from an app. I would like to know a secure way of managing their session.</p>
  
  <p>Username + password is passed over the socket to the server. The server confirms this is correct.</p>
  
  <p>I believe that I now need to generate a unique token to send back to the client.</p>
  
  <p>Now if the user closes the app, then opens it again, this token can be passed to the server and thus the server will confirm the user is authenticated again.</p>
  
  <p>Potentially though, this token could be used by somebody else to gain access to this persons account. Is there a way to prevent this?</p>
  
  <p>Is there a more secure way (whilst still maintaining the ability for the user to authenticate without logging in again)?</p>
  
  <p>How would you handle connections from other devices using the same login. Do they get a different token or the same token?</p>
  
  <p>Many thanks.</p>