Session Timeout Configurations
What you'll learn: How to configure when sessions expire to balance security with user convenience.
Understanding Session Timeouts
Session timeouts automatically end inactive or long-lived sessions, reducing the window for attackers to exploit stolen session tokens. There are two fundamental timeout types:
Absolute Timeout means the session dies after a fixed duration from creation, regardless of activity. Think of it like a movie ticket valid only for today's 7 PM showing—even if you arrive late, it expires when the show ends.
Idle Timeout (or inactivity timeout) resets with each user action. The session ends only after a period of no activity. This is like a gym locker that stays yours as long as you keep using it, but locks you out after 30 minutes of inactivity.
Choosing Appropriate Values
Timeout values depend on your application's risk profile:
- High-security systems (banking, admin panels): 5-15 minute idle timeout, 1-2 hour absolute timeout
- Standard web apps: 30-60 minute idle timeout, 8-24 hour absolute
- Low-risk systems: Longer timeouts for convenience
Balance security (shorter = safer) against usability (longer = less annoying re-logins).
Sliding Expiration Windows
Modern implementations use sliding expiration: the timeout extends with each request, but only up to the absolute limit. Configure this at session creation:
Session timeout: 30 minutes idle
Absolute maximum: 8 hours from creation
Each valid request: reset idle timer (if absolute limit not reached)
When the user clicks at minute 29, their session gets another 30 minutes—but never beyond the 8-hour absolute cap. This provides both convenience and security boundaries.
Key Takeaway: Use idle timeouts for inactivity protection and absolute timeouts as a hard security boundary, implementing sliding expiration to balance user experience with session hijacking risk.