Skip to content

Instantly share code, notes, and snippets.

@lukyans
Last active April 3, 2017 17:49
Show Gist options
  • Save lukyans/23a00838f9b9504e9aeb1321f09f2699 to your computer and use it in GitHub Desktop.
Save lukyans/23a00838f9b9504e9aeb1321f09f2699 to your computer and use it in GitHub Desktop.
Sessions, Cookies, and Flashes
If we didn't have cookies and sessions, what would happen?
Web users must agree to let cookies be saved for them, but, in general, it helps Web sites to serve users better. So user can visit pages without it.
What is a cookie?
Cookies are session token, user preferences, or anything else that the web site needs to keep track of you from one request to the next.
What's the difference between a cookie and a session?
The main difference between a session and a cookie is that session data is stored on the server, whereas cookies store data in the visitor's browser.
What's serialization and how does it come into play with sessions?
Serialization is the process of converting an object into a stream of bytes in order to store the object or transmit it to memory, a database, or a file
Why would we want to store a user id in a session?
For server to track a specific user for this session.
What is a flash? How long does a flash have before it expires?
Flash is a pop up message that is stored in Controller. It expires with each time controller being updated or called.
What syntax would I use to add a user_id key and value to the session?
session[:user] = "value"
What does "HTTP is stateless" mean?
means each request is new for server.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment