# Request.session\_options broken?

**URL:** <https://www.ruby-forum.com/t/request-session-options-broken/178884>\
**Category:** Rails\
**Created:** [November 13, 2009, 12:26am UTC](https://www.ruby-forum.com/t/request-session-options-broken/178884 "2009-11-13T00:26:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![james](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@james](https://www.ruby-forum.com/u/james)\
**Post date:** [November 13, 2009, 12:26am UTC](https://www.ruby-forum.com/t/request-session-options-broken/178884/1 "2009-11-13T00:26:01Z")

</div>

I’m implementing simple “remember me” functionality for logging in  
users with Rails 2.3.4. I’m trying to set the session expiration date  
for some time in the future. After googling around a bit I found this  
post which seems to address my problem:

[http://squarewheel.pl/posts/3](http://squarewheel.pl/posts/3)

My modifications to request.session\_options are being ignored.  
According to this discussion (  
[http://groups.google.com/group/rubyonrails-talk/browse\_thread/thread/f2e945a4b1ce3cf2/b2ba91b16a10fd0d?#b2ba91b16a10fd0d](http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/f2e945a4b1ce3cf2/b2ba91b16a10fd0d?#b2ba91b16a10fd0d)  
) using request.session\_options to modify your session cookie is  
currently broken. Is that correct?

Thanks!  
James

---

<div class="post-metadata">

**Author:** ![james](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@james](https://www.ruby-forum.com/u/james)\
**Post date:** [November 13, 2009, 10:35am UTC](https://www.ruby-forum.com/t/request-session-options-broken/178884/2 "2009-11-13T10:35:24Z")

</div>

I am also looking for a solution to this problem. It took me long  
enough to figure out how to set the cookie domain going from Rails  
2.2.2 to 2.3.4, now my cookies appear to expire daily instead of  
never ☹

---

<div class="post-metadata">

**Author:** ![james](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@james](https://www.ruby-forum.com/u/james)\
**Post date:** [November 13, 2009, 9:04pm UTC](https://www.ruby-forum.com/t/request-session-options-broken/178884/3 "2009-11-13T21:04:09Z")

</div>

If you want all of the session info for your app to persist you can  
set the expiration in config/initializers/session\_store.rb

ActionController::Base.session = {  
:key =\> ‘\_blog\_session’,  
:domain =\> ‘.example.com’,  
:expire\_after =\> 1.week # put whetever expiration you want here  
}

My issue is that I only want to set the expiration to something longer  
when the user explicitly asks me to.
