Session-Based Authentication

A session-based architecture commonly stores a session identifier in a secure cookie while the server maintains session state.

Cookies should normally use appropriate security attributes such as HttpOnly, Secure, and an intentional SameSite policy.

An HttpOnly cookie cannot be read by normal client-side JavaScript, reducing exposure to some token theft scenarios.

Key Takeaways
  • Session cookies can keep authentication state out of application JavaScript.

  • Use secure cookie attributes.

  • Authentication architecture must consider CSRF, XSS, session fixation, and logout behavior.