views:

819

answers:

4

Apparently, after upgrading to Rails 2.3 my session storage has stopped working. I used to have this:

session :session_expires => 3.years.from_now

in my application_controller.rb, but now every time i close the browser (chrome) the session expires. I read from somewhere that session_expires would have changed to expire_after, but

session :expire_after => 3.years.from_now

didn't do any good eihter.

+2  A: 

Ok, don't know why "session :expire_after => ..." didn't work, but i got it working with this:

ActionController::Base.session_options[:expire_after] = 3.years

A: 

What file should I add the above line (ActionController::Base...) to? environment.rb or application_controller.rb? Do I new to do anything to set things up in preparation (e.g., a rake command or something)?

Thanks!

A: 

Hmm, for some reason i can't comment directly to the answer, so this is for user309456: i put it in application_controller.rb. Restating the server afterwards might be a good idea, though don't know if it's necessary in development mode.

JussiR
A: 

Place this into your ApplicationController and just as your session expires a new one will be generated.

  before_filter :change_session_expiration_time

  def change_session_expiration_time    
      request.session_options[:expire_after] = 1.minute
  end
Comptrol