O'Reilly logo

RailsSpace: Building a Social Networking Website with Ruby on Rails™ by Aurelius Prochazka, Michael Hartl

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 7. Advanced login

Although the basic login functions in Chapter 6 are probably already good enough for government work, there’s one feature we’d like to add that turns out to be both challenging and instructive: a “remember me” box that, when checked, allows RailsSpace to remember the login status of its users. Like basic login, this involves using the session to maintain user state, but it also requires using browser cookies (and the methods Rails has for manipulating them). Cookies represent a more permanent way of maintaining state than the session, allowing us to remember users even after they’ve closed their browsers.

Implementing the “remember me” feature is surprisingly complicated, producing rather bloated and ugly code. Before ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required