ChapterÂ 13.Â Sessions and Cookies
The Web was built to do one thing at a time. Each request is, from the point of view of the client and server, completely independent of every other. A group of requests might all operate on the same database, and there can be clear paths from one part of an application to another, but for the most part, HTTP and scalable web application design both try to keep requests as independent as possible. It makes the underlying infrastructure easier.
Rails balances that simplicity of infrastructure with application developersâ need for a coherent way to maintain context. Rails supports several mechanisms keeping track of information about users. If you want to keep track of users manually, you can work with cookies. If you want to keep track of users for a brief series of interactions, Railsâ built-in session support should meet your needs.
If you want to keep track of users on a long-term basis, youâll want to use the authentication tools covered in ChapterÂ 14.
Getting Into and Out of Cookies