Next.js
/Intermediate
Session Authentication
Definition
A stateful authentication mechanism where the server stores active session data in a database, and the user's cookie only contains an opaque random string (Session ID).
Explain Like I'm New
Like a coat check at a club. You give the server your coat (credentials). The server hangs it on hook #42 (database row) and gives you a ticket that says '#42' (Session Cookie). When you return, the server looks up hook #42 to see who you are.
Real World Example
Highly secure applications (like banks) that require the ability to instantly 'Revoke' a session. If a user loses their laptop, the bank deletes row #42 from the database. The user's cookie immediately stops working.
Common Use Cases
- •High-security apps
- •Applications requiring session revocation
Interactive Example
Loading...
Console output will appear here...
Interview Questions
basic
- In Session Authentication, does the cookie contain the user's email address?
intermediate
- What is the primary performance drawback of Session Authentication compared to JWT?