unable to create or save session after app runs 24 hours

Hi there,

I know there is a lot of threads on here about sessions, but I could not
seem to find anyone experiencing this same issue, so alas I made a new
thread :slight_smile:

Ultimately I am stumped. I am by no means a rails expert, but have done
quite a few apps now and have yet to have any major issues w/ sessions.
I am using rails 2.0.2 on this particular project, and I am using the
active record session store.

I have in my application.rb:

session :session_expires => Time.now + 1.day

and then I have a before_filter in application.rb, that checks to make
sure the user has visited the terms and conditions page, before allowing
them to visit any other page in the application.

so for the first 24 hours after starting the application (running
lighttpd 1.4.19 w/ fastcgi), things work beautifully, for all users.

then after 24 hours passes, all of the sudden, the system appears that
it is unable to save any more sessions, and it happens for anyone on the
site.

so even if i visit the site with a different ip, and absolutely no
cookies present, i am unable to get it to save a new session, and the
application is effectively broken. this particular project has a terms
and conditions page that the user must agree to before entering the
site. the application realizes that the session is new, so it forces
them to visit this page, but it gets stuck in a never-ending-loop,
because since the session is not saved at all, upon the next page load,
it just goes back to the terms and conditions page. no cookie is set in
the browser, so that rails can identify the session.

anyone else had an experience like this, where rails is unable to save
the session and/or set the session cookie, after 24 hours of running
things in production?

Any help would be super appreciated.. Let me know if there is any
crucial pieces of information that I forgot to include. Happy 4th of
July if you happen to be in the usa today :slight_smile:

You need to think about when this code executes. application.rb is
loaded precisely once by the fastcgi listener and so that line is
evaluated exactly once, ie :session_expires is not being set to when a
request arrives + 1 day, but to when the server was started + 1 day.

Fred

Frederick Cheung wrote:

ie :session_expires is not being set to when a
request arrives + 1 day, but to when the server was started + 1 day.

"aha"! Thank you very much. That makes perfect sense. After
researching this a bit with the new info, I think I may give sliding
sessions a try as that seems to make sense for my application.

Have a great day.