开发者

How do I manipulate my session's expiry time after Rails app initialization?

I'm using the dalli memcached client for session storage in my Rails app. I'd like to allow users to check a 'Keep me signed i开发者_如何学JAVAn' box when they login to the app, which will cause the session to expire after a month or something. It's pretty straightforward to set the expiration time in the app initialization:

config/initializers/session_store.rb

require 'action_dispatch/middleware/session/dalli_store'
Rails.application.config.session_store :dalli_store, :memcache_server => ['host1', 'host2'], :namespace => 'sessions', :key => '_foundation_session', :expire_after => 30.minutes

But how would I go about manipulating :expire_after after the app has been initialized?


Im not sure this work for you , but in Rails 2.3 with db session store you could use somthing similar in your action .

request.session_options = request.session_options.dup
request.session_options[:expire_after] = 5.minutes
request.session_options.freeze

I hope it is useful

edit: I found this new article for rails3

http://augustl.com/blog/2010/dynamic_session_expiration_time_in_rails_3

I hope it is useful

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜