Antony
Antony

Reputation: 1754

How can I set a configurable timeout value for a session in Rails 3?

I am new to Rails. We are using rails 3. I would like to know how I can set a configurable session timeout value for our Rails application.

Upvotes: 3

Views: 6706

Answers (2)

0x4a6f4672
0x4a6f4672

Reputation: 28245

In Rails 3 config.action_controller.session does not work. You can configure the application's session data in the initializer file config/initializers/session_store.rb

MyApp::Application.config.session_store :cookie_store, 
        :key => '_my_session', 
        :expire_after => 30.minutes

Upvotes: 15

Ashish
Ashish

Reputation: 5791

In environment file set:

config.action_controller.session = {
  :key          => 'whatever',
  :secret       => 'nottellingyou',
  :expire_after => 30.minutes
}


OR 


session :session_key => 'my_session_key'
session :session_expires => 1.day.from_now

Upvotes: 2

Related Questions