Re: [Express-js] Multiple sessions being created per user.

287 views
Skip to first unread message

Matthew Page

unread,
May 12, 2013, 10:16:12 AM5/12/13
to expre...@googlegroups.com
Are you certain your session cookies are being set?
If you hadn't said that you have a single redis instance, I would suspect the load balancer.
That said, it might be easier to debug if you enable server affinity cookies.



On Thu, May 9, 2013 at 12:45 AM, Bg Sosh <bgs...@gmail.com> wrote:
I'm seeing multiple sessions being generated per user, and am having trouble diagnosing the problem.

- Multiple express instances loadbalanced behind haproxy
- Session store shared via connect-redis
- Session cookies scoped to '.ourdomain.com', (so should apply to 'ourdomain.com' and 'sub.ourdomain.com')
- Authentication with passport
- Express v3.2.1

Since I can see the sessions being added to the single redis instance, I'm assuming the shared store must be working ok.
So then, what might be causing multiple sessions to be generated? Is there any way to switch on debug logging for express sessions? (e.g. id like to be able to see which instance is creating a particular session).

Any tips on what to check would be much appreciated....

--
You received this message because you are subscribed to the Google Groups "Express" group.
To unsubscribe from this group and stop receiving emails from it, send an email to express-js+...@googlegroups.com.
To post to this group, send email to expre...@googlegroups.com.
Visit this group at http://groups.google.com/group/express-js?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Bg Sosh

unread,
May 13, 2013, 3:28:21 PM5/13/13
to expre...@googlegroups.com
Yes, I can confirm that cookies are being set.  

Strangely this is also happening when I take down all the nodes but one (so there is only one instance serving).  Can anyone offer any suggestions about what might cause multiple sessions to be generated?

Also, how might I go about debugging session creation?  Is there any way I can log more information about what's going on under the hood?

Thanks

Thomas Blobaum

unread,
May 13, 2013, 3:41:16 PM5/13/13
to expre...@googlegroups.com
Are you serving static files?


Thomas Blobaum

Bg Sosh

unread,
May 14, 2013, 4:34:14 AM5/14/13
to expre...@googlegroups.com
Static files should be coming from a seperate nginx server, I'll double check that nothing is coming from the app servers (there are static use() settings in there from development).  Out of interest - Why would that cause this behaviour? Will report back.  

Bg Sosh

unread,
May 14, 2013, 5:46:10 AM5/14/13
to expre...@googlegroups.com
Nothing static was being served from the app servers.  I had previously moved the static setup above the session for this reason, but have now removed it completely for production to check.  Any other ideas?

Jef Harkay

unread,
Jan 27, 2014, 11:45:45 AM1/27/14
to expre...@googlegroups.com
Did you ever figure this out?  I'm having a similar issue, but I get 2 sessions created per user, whether it's a MemoryStore or MongoStore... the actual session I care about contains information about the user, so when I destroy the user's session, I'm left with 1 session that doesn't contain this information, which means it's getting created somewhere else... I've tried looking at setting the key, but that didn't fix anything.
Reply all
Reply to author
Forward
0 new messages