SessionManager class

Main Session Manager Orchestrates session operations using dependency injection

Implemented types

Constructors

SessionManager({required ISessionDriverRegistry driverRegistry, required String driverName, SessionIdGenerator? idGenerator, SessionCookieHandler? cookieHandler, SessionValidator? validator, Duration maxAge = const Duration(hours: 24)})
SessionManager.fileBased({String sessionPath = 'storage/sessions', Duration maxAge = const Duration(hours: 24), SessionCookieHandler? cookieHandler})
Factory constructor for file-based storage
factory

Properties

driverName String
Get current driver name
no setteroverride
driverNames List<String>
Get all available driver names
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

cleanupExpiredSessions() Future<void>
Cleanup expired sessions
override
clearSessionCookie(HttpResponse response) → void
Clear session cookie
override
createSession([Map<String, dynamic> initialData = const {}]) Future<String>
Create a new session
override
destroySession(String sessionId) Future<void>
Destroy session
override
flash(String sessionId, String key, dynamic value) Future<void>
Flash data to session
override
flashOldInput(String sessionId, Map<String, dynamic> inputData) Future<void>
Flash old input data to session for form repopulation
override
getFlashed(String sessionId, String key) Future
Get flashed data (and clear it)
override
getOldInput(String sessionId) Future<Map<String, dynamic>?>
Get and clear flashed old input data
override
getSession(String sessionId) Future<Map<String, dynamic>?>
Get session data
override
getSessionIdFromRequest(HttpRequest request) String?
Get session ID from request
override
getSessionValue(String sessionId, String key) Future
Get session value
override
hasValidSession(String sessionId) Future<bool>
Check if session exists and is valid
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
regenerateSession(String oldSessionId) Future<String>
Regenerate session ID
override
removeSessionValue(String sessionId, String key) Future<void>
Remove session value
override
setSessionCookie(HttpResponse response, String sessionId) → void
Set session cookie
override
setSessionValue(String sessionId, String key, dynamic value) Future<void>
Set session value
override
switchDriver(String driverName) Future<void>
Switch to a different driver
override
toString() String
A string representation of this object.
inherited
updateSession(String sessionId, Map<String, dynamic> newData) Future<void>
Update session data
override

Operators

operator ==(Object other) bool
The equality operator.
inherited