Sessions
Definition
A server-side data store that temporarily holds information about a specific user's interaction with the application, linked to the user via a Session ID stored in a client-side cookie.
Explain Like I'm New
Cookies hold very little data (4KB limit) and can be tampered with. So, the server creates a 'Folder' on its own hard drive for you, puts all your data in it (Shopping Cart, Auth Status), and gives the folder a random serial number. It hands you a Cookie containing ONLY that serial number. This is a Session.
Real World Example
Logging into a bank. The bank server creates a Session in its memory. If the bank detects suspicious activity, they simply delete the Session from their memory. Your cookie still exists, but the serial number now points to a deleted folder, instantly locking you out.
Common Use Cases
- •Authentication
- •Shopping carts
- •Multi-step wizards
Interactive Example
Interview Questions
basic
- Where is the actual user data (like their email or cart items) stored in Session-based architecture?
intermediate
- Why are Sessions considered 'Stateful' architecture?