← Back to demos

Session Timeout / Idle Detection

Stop moving your mouse for 5 seconds to trigger the idle warning.

Idle timeout: 5s • Warning duration: 10s

Move mouse here ↓
State Machine Approach
active
Clean state transitions with automatic timer management.

Session Active

Move your mouse to stay active

State Machine Benefits:

  • • Entry/exit actions auto-manage timers
  • • Can't be "active" AND "warning" simultaneously
  • • ACTIVITY event works in both states (explicitly defined)
  • • Guard prevents logout until countdown reaches 0

Real-World Application:

Banking apps, admin dashboards, and security-sensitive applications all need idle detection. The state machine approach makes the flow explicit: active → idle warning → logged out. Timer cleanup is automatic via entry/exit actions. No orphaned timers, no race conditions.