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 - Ruby on Rails Tutorial
From the course: Ruby on Rails 5 Essential Training
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.