RailsSpace: Building a Social Networking Website with Ruby on Rails™
by Michael Hartl, Aurelius Prochazka
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access