Skip to content

Instantly share code, notes, and snippets.

@VikiAnn
Last active August 29, 2015 14:10
Show Gist options
  • Save VikiAnn/a0394602fbf2fc9b8ab4 to your computer and use it in GitHub Desktop.
Save VikiAnn/a0394602fbf2fc9b8ab4 to your computer and use it in GitHub Desktop.
1. What's the difference between a cookie and a session?
Maybe cookies are more complicated. A session starts when a user logs in, and maybe you don't need a logged-in state for a cookie?
2. What's serialization and how does it come into play with cookies?
I have no idea.
3. Can a cookie be shared by more than one user? How/why?
I don't think so... a cookie is stored on a machine, isn't it? Or in the browser? Maybe if you have two people using the same machine, but it'd still be a different cookie if they had different browsers and stuff...
4. What would it mean to store a shopping cart in a cookie?
Uh... So a cookie is some kind of file stored in a browser on a machine, and I guess you can store a cart or whatever in that file.
5. What advantages/disadvantages are there between cookie-stored carts and
database-stored carts?
I'm not sure, but I've heard that database-stored carts clutter up your database with abandoned carts, while a cookie-stored or session-based (are these actually interchangable?) cart wouldn't end up in your database until it became an order.
--------------------------
NOTES
In request/response loop, a cookie can be a part of the response
Cookie
-string of data
-use persist state across request
Client stores cookie, doesn't/can't take action on it
Client includes cookie in the next request
Server recognizes cookie as its own, decrypts, does some stuff, sends it back encrypted
Should store as little as possible in the cookie, don't want something like price that a user can modify.
Serialization: turning rich objects into strings (and back again?)
JSON, XML, YML can be used for this
Can't store symbol in session as JSON, just turns into a string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment