Test Your Knowledge
Quiz
How much information should you store in cookies?
How do you specify how long a cookie will last?
Where does Rails normally store the information you put in the cookie object?
What does calling
flash.nowdo?
Answers
You should store as little information in cookies as your application can manage.
Cookie lifespans default to expiring when the user quits the browser, but can be set to more specific lengths of time with the
:expiresparameter.By default, Rails stores the cookie objects information directly in the cookie, on the user’s browser, but note that you can change this by modifying your config/environment.rb file.
The
flash.nowmethod lets you set a value to be sent to the user, but ensures that the value will be cleared before any reloads or redirects.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access