Session Management
GRIPLOCK implements activity-based session management to balance security with user experience. Sessions automatically expire after inactivity while remaining persistent across page refreshes.Session Lifecycle
Session Properties
| Property | Value | Description |
|---|---|---|
| TTL | 15 minutes | Time-to-live after last activity |
| Storage | Encrypted localStorage | Persists across page refresh |
| Reset Events | Mouse, click, scroll, keyboard, touch | Any user interaction resets timer |
| Cleanup | Automatic | Expired sessions cleared on check |
Activity Detection
GRIPLOCK monitors multiple user interaction types to reset the session timer:Why These Events?
| Event | Rationale |
|---|---|
mousemove | Indicates active viewing/reading |
click | Direct interaction with UI |
scroll | Browsing content |
keydown | Any keyboard input |
touchstart | Mobile device interaction |
Session Timer Implementation
State vs Storage Updates
GRIPLOCK separates state updates from storage writes for performance:- UI timer displays accurately
- Storage I/O doesn’t impact performance
- Session persists across refresh
Timer Display
The dashboard shows remaining session time:Session Persistence
Storage Format
Sessions are stored as encrypted blobs:Encrypted Payload
Encryption Key
The storage encryption key is derived from the session ID:- Session ID is required to decrypt stored credentials
- Different sessions use different encryption keys
- Session ID loss = credentials inaccessible
Session Restoration
On page load, GRIPLOCK attempts to restore an existing session:Security Measures
Automatic Expiration
Manual Logout
Browser Close Behavior
| Storage Type | Behavior |
|---|---|
localStorage | Persists until expiration or manual clear |
sessionStorage | Cleared when browser tab closes |
sessionStorage acts as an additional security layer:
- Closing the browser requires re-authentication
- Session data remains encrypted but inaccessible
Configuration
TTL Adjustment
The default 15-minute TTL can be configured:Activity Throttle
Storage write throttling prevents excessive I/O:- Expected user activity patterns
- Storage performance requirements
- Battery/CPU considerations for mobile
Edge Cases
Page Refresh During Activity
Page Refresh During Activity
Session survives refresh. The throttled storage write ensures recent activity is persisted. On restore, TTL is reset to full 15 minutes.
Multiple Tabs
Multiple Tabs
Each tab maintains its own session. Storage is shared, but session ID in sessionStorage is per-tab.
Browser Crash
Browser Crash
If the browser crashes without a recent storage write, up to 5 seconds of activity may be lost. Session restores to last persisted state.
Clock Skew
Clock Skew
Expiration uses
Date.now() on the client. Large clock changes could cause premature expiration or extended sessions.Best Practices
Logout When Done
Always manually log out when finished, especially on shared computers
Use Private Browsing
For maximum security, use incognito/private mode to ensure session data isn’t persisted
Monitor Session Timer
Keep an eye on the remaining session time displayed in the dashboard
Physical Security
Keep your NFC card secure and don’t share your PIN
