title: In node.js, how do I setup redis with socket.io and express? Specifically using RedisStore()
body: <p><strong>First Problem</strong> <br>
  I'm trying to figure out sessions, stores, authorization, and redis. If it's important, I am using <code>Express@3.0.0rc4</code>. I understand that I have two options to put my <code>RedisStore()</code>. Which one do I use? Do I use both?</p>
  
  <pre><code>express.session({secret: 'secret', key: 'key', store: new RedisStore()});
  io.set('store', new RedisStore());
  </code></pre>
  
  <p>I already have <code>node.js</code>, <code>express</code>, and <code>socket.io</code> running. So now I'm trying to implement <code>redis</code> but I don't know how to implement authorization using sessions/stores and I don't know how to write to the redis database. I haven't found any documentation on this. I found a site that talks about sessions and stores using <a href="http://www.danielbaulig.de/socket-ioexpress/" rel="noreferrer">socket.io and express</a> but no redis, and another one that talks about sessions and stores <a href="http://iamtherockstar.com/blog/2012/02/14/nodejs-and-socketio-authentication-all-way-down/" rel="noreferrer">using all three</a>, but it doesn't use <code>io.set('store', ...)</code>.</p>
  
  <p>I also don't know if I should use two different stores, one for <code>express</code> and one for <code>socket.io</code>, or if I should just use one. Look at the example for clarification:</p>
  
  <pre><code>//Redis Variables
  var redis = require('socket.io/node_modules/redis');
  var RedisStore = require('socket.io/lib/stores/redis');
  var pub = redis.createClient();
  var sub = redis.createClient();
  var client = redis.createClient();
  var redis_store = new RedisStore({
                          redisPub: pub,
                          redisSub: sub,
                          redisClient: client
                        });
  
  app.configure(function(){
    //...code goes here...
    app.use(express.session({
                      secret: 'secret',
                      key: 'key',
                      store: redis_store  //Notice I'm using redis_store
                    }));
    //...more code...
  });
  
  io.configure(function(){
    io.set('store', redis_store);  //Notice it's the same RedisStore() being used
  });
  </code></pre>
  
  <p>Do I use the same <code>RedisStore()</code> for each? Do I create seperate ones for each? Do I just use <code>express</code> or <code>socket.io</code>? What I really want is to be able to authenticate clients (I assume that's done through sessions) and have them update the redis database when they connect - keeping a log of when people accessed my site. Which leads to my second problem.</p>
  
  <p><hr>
  <strong>Second Problem</strong><br>
  So I have no idea how to access and edit the redis database from this point. I haven't been able to test this because of my first problem but I assume it would be something like this:</p>
  
  <pre><code>io.sockets.on('connection', function(socket){
    var session = socket.handshake.session;
    redis.put(session);
  });
  </code></pre>
  
  <p>I also haven't seen any documentation on how to update a redis database from within node.js so I <em>highly doubt</em> that <code>redis.put()</code> is the correct terminology haha. I have visited <a href="http://redis.io/" rel="noreferrer">redis's website</a> but I can't find commands for node.js. Just commands for using regular redis from the command line. Anyways, if someone could at least point me in the right direction that would be great. Thanks. :)</p>