From the course: Ruby on Rails 5 Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Cookies

Cookies - Ruby on Rails Tutorial

From the course: Ruby on Rails 5 Essential Training

Start my 1-month free trial

Cookies

- [Instructor] One of the challenges of building web applications is that the web is a stateless environment. When web servers respond to requests for pages, each request is treated as a new request, and the web server doesn't know, keep track of, or care about what previous requests have been made. It doesn't know what a user has selected or clicked on previously, and doesn't even know if the user is logged in or not. Cookies help us to solve the problem of the stateless web. A web server can send data to the user's browser for storage in a browser cookie. Then with each subsequent request to the web server, the browser will send along that cookie data. A cookie might track what the user last clicked on, or it might include the user's location, language preferences, or search settings. And this allows an application to maintain the state of a user's interaction. Cookies in Rails work just like a hash of values. So we can assign a value to a cookie by simply calling cookies, plural…

Contents