hi everyone, i can''t seem to find any help online for this. I''m using CookieStore. What I can''t seem to figure out how to do is set the expiration for the cookie set by CookieStore. Right now it leaves that field blank, meaning that the cookie expires when the browser is closed. The context is for a login, where the user has the option to check a "leave me logged in" option that would expire the cookie 2 weeks or 3 weeks later. thanks, etienne
cookies[:key] = {:value => value, :expires => 3.weeks.from_now} On May 1, 9:41 am, etienne <pelap...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> hi everyone, > > i can''t seem to find any help online for this. I''m using > CookieStore. What I can''t seem to figure out how to do is set the > expiration for the cookie set by CookieStore. Right now it leaves > that field blank, meaning that the cookie expires when the browser is > closed. The context is for a login, where the user has the option to > check a "leave me logged in" option that would expire the cookie 2 > weeks or 3 weeks later. > > thanks, > etienne
That overwrites the cookie for the session. By the time they attempt to login, a session has already begun for them. CookieStore is doing the management behind the scenes. I want to amend the cookie to have an expiration date which, it seems, it does not have by default. etienne On May 1, 10:17 am, "E. Litwin" <elit...-ur4TIblo6goN+BqQ9rBEUg@public.gmane.org> wrote:> cookies[:key] = {:value => value, :expires => 3.weeks.from_now} > > On May 1, 9:41 am, etienne <pelap...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > hi everyone, > > > i can''t seem to find any help online for this. I''m using > > CookieStore. What I can''t seem to figure out how to do is set the > > expiration for the cookie set by CookieStore. Right now it leaves > > that field blank, meaning that the cookie expires when the browser is > > closed. The context is for a login, where the user has the option to > > check a "leave me logged in" option that would expire the cookie 2 > > weeks or 3 weeks later. > > > thanks, > > etienne
etienne <pelaprat-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:> That overwrites the cookie for the session. By the time they attempt > to login, a session has already begun for them. CookieStore is doing > the management behind the scenes. I want to amend the cookie to have > an expiration date which, it seems, it does not have by default. > etienneTry this in your config/environment.rb config.action_controller.session = { :session_key => ''_yourapp'', :secret => ''yoursecret'', :expire_after => 600 # seconds } It works for me. Jarl