8.4 Remember Me

The login system we finished in Section 8.2 is self-contained and fully functional, but most websites have the additional capability of remembering users’ sessions even after they close their browsers. In this section, we’ll start by remembering user logins by default, expiring sessions only when users explicitly log out. In Section 8.4.5, we’ll enable a common alternative model, a “remember me” check box that allows users to opt out of being remembered. Both of these models are professional-grade approaches, with the first being used by sites such as GitHub and Bitbucket, and the second being used by sites such as Facebook and Twitter.

8.4.1 Remember Token and Digest

In Section 8.2, we used the Rails session method to store ...

Get Ruby on Rails Tutorial: Learn Web Development with Rails, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.