Skip to content

Instantly share code, notes, and snippets.

@seth-at-at
Created April 3, 2017 16:42
Show Gist options
  • Save seth-at-at/b6c508ed355bfc22149fafe5fc4ba073 to your computer and use it in GitHub Desktop.
Save seth-at-at/b6c508ed355bfc22149fafe5fc4ba073 to your computer and use it in GitHub Desktop.

Sessions, Cookies, and Flashes

  1. If we didn't have cookies and sessions, what would happen?
  • We would not have a convenient way to store data from users
  1. What is a cookie?
  • Cookies are small files which are stored on a user's computer very similar to a hash
  • They are designed to hold data specific to a particular client and website.
  1. What's the difference between a cookie and a session?
  • Session data is stored on the server
  • Cookies data is stored on visitor's browser
  1. What's serialization and how does it come into play with sessions?
  • It encrypts the data stored and prevent human tampering
  1. Why would we want to store a user id in a session?
  • To keep specific data saved to that user
  1. What is a flash? How long does a flash have before it expires?
  • A flash is a hash you can store messages in and have appear on screen to tell the user something
  • A flash has until it's used before it's expired
  1. What syntax would I use to add a user_id key and value to the session?
  • session[:user_id] = value
  1. What does "HTTP is stateless" mean?
  • Connection between the browser and the server is lost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment