title: How do you pass php session data to socket.io?
body: <p>I'm writing an application where a user can be logged in from several browsers at once, with a connection being established to socket.io on the server when the page loads.</p>
  
  <p>I want to keep track of all client socket id's, <code>socket.id</code>, in a redis set whose key would look like <code>userId:???:socketClientIds</code> for that logged in user.  I want to <a href="http://redis.io/commands/sadd" rel="nofollow">SADD</a> the socket client id to the redis set after an php script is called via ajax.</p>
  
  <p>Since I keep the user id in a php session variable <code>$_SESSION['userId']</code>, what is a safe/practical way I can communicate the value of this user id to socket.io so I can add the client id to the set?</p>
  
  <p><code>client.sadd("userId:???:socketClientIds", socket.id)</code></p>
  
  <p>I can't trust the client to provide an accurate value for a userId because it might be forged.</p>