0

I'm using redisStore in express.

User session data is available at something like sess:eI6Jnj0gzMkdEvszUciqbcJ9, if i do:-

redisClient.set('sess:eI6Jnj0gzMkdEvszUciqbcJ9', 'something', function(err){
  console.log(err || ' session changed');
});

'session changed' actually prints on console. but sess:eI6Jnj0gzMkdEvszUciqbcJ9 is not updated in database. I'm presuming, express does not permit redisClient.set to change the session data. How may i achieve it?

PS. The change works on my localhost but does not work, once i use redistogo on heroku.

Edit:-

I check the key not updating, by runnign get 'sess:eI6Jnj0gzMkdEvszUciqbcJ9' command on the console. i am using redis.createClient

var redisClient = require('redis').createClient( 3374, 'birdeye.redistogo.com', {detect_buffers: true});
redisClient.auth('052cb8c4142g202f7878588dd5fb129', function() {
    console.log('Redis client connected');
});

I am only guessing that express.js may be 'updating its session automatically Probably, it simply overwrites all your changes with req.session.'

Sangram Singh
  • 7,161
  • 15
  • 50
  • 79
  • How is this question different from [this one](http://stackoverflow.com/questions/20334805/redisclient-set-no-update-no-error) and [this one](http://stackoverflow.com/questions/20331355/redis-session-key-not-updating)? Express does not (and AFAIK, **can** not) impose any restrictions on what's being stored in Redis. How do you check what's being stored in your database? – robertklep Dec 03 '13 at 07:10
  • @robertklep this is the latest draft. Where it figures, redisClient.set on a key which express set does not update. Am i being a bad boy? – Sangram Singh Dec 03 '13 at 07:23
  • How do you *specifically* check if the key doesn't update in the database? Do you use a Redis client? Are you making assumptions that because Express doesn't see the new data, it isn't updated? Also, it's customary to edit previous questions to add more details, instead of creating new ones each time you get a new piece of information. – robertklep Dec 03 '13 at 07:28
  • @robertklep let me not defend myself. Honestly, you're right. But i'm just stuck on this issue for 2 days, now. answering your points in the edit. – Sangram Singh Dec 03 '13 at 07:31
  • I think Express might be overwriting the session, especially since you seem to be changing it from 'somewhere else'. – robertklep Dec 03 '13 at 07:47
  • It works fine on localhost. So I am guessing I shd be able to change settings from somewhere. – Sangram Singh Dec 03 '13 at 07:54
  • localhost might seem to work if you're testing it differently (only one user testing, whereas on Heroku you're testing with multiple users?) – robertklep Dec 03 '13 at 08:23
  • @robertklep no working with same way, single user only. same exact thing works on localhost. does not on heroku. to be precise, i'm using localhost in both cases, just the redisClient uses cloud hosting of redistogo in place of local redis server. – Sangram Singh Dec 03 '13 at 10:59

0 Answers0