Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 48887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T16:21:02+00:00 2026-05-10T16:21:02+00:00

My Rails-app has a sign in box with a remember me checkbox. Users who

  • 0

My Rails-app has a sign in box with a ‘remember me’ checkbox. Users who check that box should remain logged in even after closing their browser. I’m keeping track of whether users are logged in by storing their id in the user’s session.

But sessions are implemented in Rails as session cookies, which are not persistent. I can make them persistent:

class ApplicationController < ActionController::Base   before_filter :update_session_expiration_date    private    def update_session_expiration_date     options = ActionController::Base.session_options     unless options[:session_expires]       options[:session_expires] = 1.year.from_now     end   end end 

But that seems like a hack, which is surprising for such common functionality. Is there any better way?

Edit

Gareth’s answer is pretty good, but I would still like an answer from someone familiar with Rails 2 (because of it’s unique CookieSessionStore).

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T16:21:02+00:00Added an answer on May 10, 2026 at 4:21 pm

    I have spent a while thinking about this and came to some conclusions. Rails session cookies are tamper-proof by default, so you really don’t have to worry about a cookie being modified on the client end.

    Here is what I’ve done:

    • Session cookie is set to be long-lived (6 months or so)
    • Inside the session store
      • An ‘expires on’ date that is set to login + 24 hours
      • user id
      • Authenticated = true so I can allow for anonymous user sesssions (not dangerous because of the cookie tamper protection)
    • I add a before_filter in the Application Controller that checks the ‘expires on’ part of the session.

    When the user checks the ‘Remember Me’ box, I just set the session[:expireson] date to be login + 2 weeks. No one can steal the cookie and stay logged in forever or masquerade as another user because the rails session cookie is tamper-proof.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rails app that has asynchronous processing, and I'm having trouble getting
I have a rails app that has a private component and a public component.
I have a Rails app that has 2 clients -- an iOS app reads/writes
I'm writing a rails app that has a model called 'User' and a model
I'm building a Rails app that has Etsy.com style functionality. In other words, it's
We have a Rails app that instantiates a SWF object 16 times (it has
I have a rails app (rails 3.1.3) that has a shopping cart model. I
I've got a rails app with a posts scaffold that has just a title
Using Rails 3.1.3 with Devise 1.5.3. My app has accounts and users. Each account
My Rails app has complicated rules about when a bit of content should be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.