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 - Ruby on Rails Tutorial
From the course: Ruby on Rails 6: Controllers and Views
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…
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.
Contents
-
-
-
(Locked)
Store data in cookies7m 32s
-
(Locked)
Store data in sessions7m 55s
-
Messaging with the flash hash4m 2s
-
(Locked)
Log information to a file7m 44s
-
(Locked)
Inherit common behaviors with ApplicationController6m 28s
-
(Locked)
Use filters to call methods automatically7m
-
(Locked)
Understanding CSRF protections4m 30s
-
(Locked)
Challenge: Controllers1m 36s
-
(Locked)
Solution: Controllers3m 19s
-
(Locked)
-
-
-
-