Skip to content

Instantly share code, notes, and snippets.

@wewert
Last active April 3, 2017 17:20
Show Gist options
  • Save wewert/4b67bdb20180c1341a8accb096efc843 to your computer and use it in GitHub Desktop.
Save wewert/4b67bdb20180c1341a8accb096efc843 to your computer and use it in GitHub Desktop.
Cookies, Sessions, and Flashes Questions
Sessions, Cookies, and Flashes
If we didn't have cookies and sessions, what would happen? Everytime you leave a webpage it would ground hogs day. There would be not "login" that would work.
What is a cookie? A special object that is a key value type that is stored until it expires and used to persist state while user moves from page to page for example.
What's the difference between a cookie and a session? Cookies expire and sessions are done once the user closes the browser.
What's serialization and how does it come into play with sessions? Serialization keeping the session encrypted.
Why would we want to store a user id in a session? So, the user can stay logged in the whole time they are using the browser.
What is a flash? How long does a flash have before it expires? A special object that only persist from one request to another.
What syntax would I use to add a user_id key and value to the session? flash.now[:user_id] = "You are logged in"
What does "HTTP is stateless" mean? HTTP doesn't hold any modified information.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment