Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8644423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:17:24+00:00 2026-06-12T12:17:24+00:00

First Problem I’m trying to figure out sessions, stores, authorization, and redis. If it’s

  • 0

First Problem
I’m trying to figure out sessions, stores, authorization, and redis. If it’s important, I am using Express@3.0.0rc4. I understand that I have two options to put my RedisStore(). Which one do I use? Do I use both?

express.session({secret: 'secret', key: 'key', store: new RedisStore()});
io.set('store', new RedisStore());

I already have node.js, express, and socket.io running. So now I’m trying to implement redis 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 socket.io and express but no redis, and another one that talks about sessions and stores using all three, but it doesn’t use io.set('store', ...).

I also don’t know if I should use two different stores, one for express and one for socket.io, or if I should just use one. Look at the example for clarification:

//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
});

Do I use the same RedisStore() for each? Do I create seperate ones for each? Do I just use express or socket.io? 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.


Second Problem
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:

io.sockets.on('connection', function(socket){
  var session = socket.handshake.session;
  redis.put(session);
});

I also haven’t seen any documentation on how to update a redis database from within node.js so I highly doubt that redis.put() is the correct terminology haha. I have visited redis’s website 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. 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T12:17:25+00:00Added an answer on June 12, 2026 at 12:17 pm

    Express and Socket.IO have their own integration with Redis for session management, as you’ve seen. It is designed as a blackbox integration, the idea being that the session store implementation is independent from the rest of your code. Since it’s independent, that means you can’t go in and use express or socket.io to access Redis directly. You’ll need to add a regular redis client like node_redis. The benefit is you don’t have to worry about making all those redis calls yourself, instead you’ll be interacting with express or socket.io’s session store interfaces.

    So in your #1 case, you could pass in a single new instance of RedisStore, not two new ones as you’ve done. Or you could follow your second link and have socket.io listen through express. In that case it would integrate with express session management. That’s why you don’t see the extra io.set(‘store’) call in that example.

    It’ll probably seem redundant to you, but try to think of RedisStore as a special client designed only for session management. Even thought RedisStore probably relies on something like node_redis, you shouldn’t try to access it. You have to include another library for accessing your redis database directly, assuming you wanted to store other non-session items in redis in the first place.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm now already trying for hours, but somehow i don't figure out the problem.
I'm trying to use GSP outside grails and ran to my first problem. I
I'm trying to use Microsoft Expression Encoder 4.0 in my application. The first problem
Using an XDocument and the Descendants method. //first problem 'entries' doesn't fetch at all
I'm trying to get into Android app developing. My first problem is actually getting
Basically, I'm using WebGrid and I need to filter the results. The first problem
My first problem : I am currently using $(window).load to delay the page render
I just started using T4 templates and the first problem occured. When I try
I'm starting with a new application using silverlight and the first problem I have
I am just setting up a test project using Oracle Streams. My first problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.