4

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?

protometa
  • 1,603
  • 1
  • 12
  • 16
  • 1
    Oh duh... Always check your system timezone or else your sessions could be expiring instantly. My other friend's computer was brand new too so it was probably the same problem. =/ – protometa Mar 30 '12 at 17:20
  • I've seen this problem happening too for our web app. – Farid Nouri Neshat Mar 31 '12 at 04:06
  • How do I check the timezone? That's exactly what's happening too me... Adding another zero to the expires fixes it but I don't really want to add another then hours to the timeout :) – Asken Apr 06 '12 at 06:25
  • It should be in the same place that you set the clock time. – protometa Apr 07 '12 at 03:04

1 Answers1

3

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.

protometa
  • 1,603
  • 1
  • 12
  • 16