I''m having an issue with Rails version 3.0.9 and trying to get persistent cookies to stay for the existing session. I want a 1 year expire on all sessions as a default. My existing code in my session_store.rb is this: MyApplicationName::Application.config.session_store :cookie_store MyApplicationName::Application.config.session = { :key => ''_myapp_name_session'', :path => ''/'', :domain => nil, :expire_after => 1.years.from_now.utc, :secure => false, :httponly => true, :cookie_only => true, :secret => ''myLongSecretCode'' } my Curent User is defined in application controller as: def current_user @current_user ||= User.find_by_id(session[:user_id]) end I have checked my site in firefox using firecookie and it shows the cookie as session only and after I close the browser and reopen the browser, I have to log in again. How do I make this persistent? Thank you. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Also, I forgot to add I''m using Bcrypt for password authentication. I''m not sure if that makes a difference or not. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
One bump. I have not heard from anyone in 19 hours. Thanks. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
GIYF: Search term was ''rails session config'', second result seems to indicate that this expire_after option is no longer in the Active Record Session: http://stackoverflow.com/questions/5860950/setting-session-timeout-in-rails-3 Walter On Apr 1, 2012, at 12:44 PM, David Moeller wrote:> I''m having an issue with Rails version 3.0.9 and trying to get > persistent cookies to stay for the existing session. I want a 1 year > expire on all sessions as a default. > > My existing code in my session_store.rb is this: > > MyApplicationName::Application.config.session_store :cookie_store > > MyApplicationName::Application.config.session = { > > :key => ''_myapp_name_session'', > :path => ''/'', > :domain => nil, > :expire_after => 1.years.from_now.utc, > :secure => false, > :httponly => true, > :cookie_only => true, > :secret => ''myLongSecretCode'' > > } > > my Curent User is defined in application controller as: > > def current_user > @current_user ||= User.find_by_id(session[:user_id]) > end > > I have checked my site in firefox using firecookie and it shows the > cookie as session only and after I close the browser and reopen the > browser, I have to log in again. > > How do I make this persistent? > > Thank you. > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Walter Davis wrote in post #1054653:> GIYF: > > Search term was ''rails session config'', second result seems to indicate > that this expire_after option is no longer in the Active Record Session: > > http://stackoverflow.com/questions/5860950/setting-session-timeout-in-rails-3 > > WalterThanks for the reply Walter, but I ended up testing another route by going to the session_store.rb and placing in: MyApplication::Application.config.session_store :active_record_store, :key => ''_my_key'', :expire_after => 2.hours which allowed me to use the database instead. I then ran: bundle exec rake db:sessions:create bundle exec rake db:migrate And, after logging into IE and into Firefox, the sessions hold after the browser is closed. I looked at the cookies with Firecookie and saw the following: _my_key Expires: Timestamp with 2 hours later So, the expire_after works fine with Rails 3.0.10 which is what I''m using now. I just have to create a sweep routine to clean up the database when necessary; (per ruby on rails guides - section 2.9 session expiry) http://guides.rubyonrails.org/security.html#sessions -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.