Skip to content
Web Design & Development

Session Management: What Actually Works

How web applications keep users signed in between requests, using session identifiers or tokens.

Marcus Adeyemi Technical Director 2 min read 23 views
Session Management: What Actually Works

Why does it matter?

Weak session handling lets attackers hijack accounts, and session bugs cause confusing logouts and data leaks.

What are the numbers?

  • Session IDs must be random and long enough to resist guessing
  • Cookies session cookies should be HttpOnly and Secure
  • Rotation session identifiers should change after sign-in
  • Expiry sessions need both idle and absolute timeouts

What should I do?

  1. Regenerate session identifiers on privilege changes
  2. Set Secure, HttpOnly and SameSite cookie attributes
  3. Expire sessions on sign-out everywhere
  4. Store sessions server-side where practical
  5. Log unusual session activity
What to do and what to avoid with session management, side by side
Good practice against the usual mistakes, from the sources listed below.

What should I avoid?

Avoid:

  • Session identifiers in URLs
  • Sessions that never expire
  • Reusing identifiers after sign-in
  • Sensitive data in client-readable cookies

When should I get help?

Short answer Bring in help when applications handle accounts or payments.

Where this comes from

The figures and practices above come from the sources listed.

Working on something like this?

We take on Web Design & Development work for teams who want it done once, properly. Tell us what you are building and we will tell you honestly whether we are the right studio for it. Start a project.

Where to go next

Spotted something wrong? Report an error on this page. We correct on the page and say what changed.

All services

The work behind this article, and what it costs.

Marcus Adeyemi

Builds and maintains the web work. Writes about front-end architecture, performance, accessibility and the unglamorous parts of keeping a site alive.

Keep reading

More in Web Design & Development