Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

nodejs connect session cookie not setting on some machines

nodejs connect session cookie not setting on some machines

Problem

I have a minimal connect session setup on my nodejs app:

connect.cookieParser(),
connect.session({ secret: 'asdfg', cookie: { maxAge: 60 * 60 * 1000 }}),

But when testing my site on other machines the session Cookie does not get set at all. On my Mac the session cookie is set like normal in both Chrome and Firefox. On my virtual Windows the session cookie does not get set on either Chrome or Firefox. On one friend's Windows the sessions are apparently not getting set either, but on another friend's Windows the sessions seem to be working. I've checked cookie setting and headers on my virtual Windows Chrome, but nothing seems to be different, it's just refusing to create a cookie...

Any ideas why session cookies would apparently be getting set on some machines and not others?

Problem courtesy of: protometa

Solution

The answer finally dawned on me shortly after posting...

Always check your system timezone or your sessions could be expiring instantly. Even if the time is right, the timezone will offset that time from UTC which is what sessions use. It will affect the expiration time of any session, but sessions that are set to expire in only an hour or two may not get set at all.

Solution courtesy of: protometa

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

nodejs connect session cookie not setting on some machines

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×