From the course: Ruby on Rails 6: Controllers and Views

Unlock the full course today

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

Store data in cookies

Store data in cookies - Ruby on Rails Tutorial

From the course: Ruby on Rails 6: Controllers and Views

Start my 1-month free trial

Store data in cookies

- [Instructor] We're going to start things off by looking at some useful controller features, beginning with learning how cookies work in Ruby on Rails. You may already know that HTML is stateless. What that means is that each request from the browser to the web server is distinct. And the web server doesn't try and preserve state. It doesn't try and remember any information about previous requests that come in at all. Each request is unique on its own. But we can keep track of data between requests by using cookies and sessions. We'll look at sessions in the next movie. We're going to start by looking at cookies first. Cookies allow us to preserve the state of interaction with the website. The idea is that the web server sends data to the browser, which then saves that data in a browser cookie. It stores it on the user's local computer. The browser then sends that cookie data back with each and every future request to that…

Contents