Session class

Represents a session with a unique ID and associated data.

Constructors

Session({String? id, required String name, required Options options, Map<String, dynamic>? values, DateTime? createdAt, DateTime? lastAccessed})
Creates a new session with the given id and optionally values.

Properties

age int
no setter
createdAt DateTime
When the session was created.
no setter
hashCode int
The hash code for this object.
no setterinherited
id String
The unique identifier for this session.
getter/setter pair
idleTime int
no setter
isDestroyed bool
Whether the session has been destroyed.
no setter
isNew bool
Whether this is a new session
getter/setter pair
lastAccessed DateTime
When the session was last accessed.
no setter
name String
Name of the session cookie
final
options Options
The session options
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
values Map<String, dynamic>
Map containing the session data.
final

Methods

destroy() → void
Marks the session as destroyed and clears all values.
getValue<T>(String key) → T?
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
regenerate() → void
Regenerates the session ID while maintaining the session data.
serialize() String
Serializes the session to a JSON string.
setValue(String key, dynamic value) → void
toMap() Map<String, dynamic>
Convert session to a map for serialization
toString() String
A string representation of this object.
inherited
touch() → void
Updates the last accessed time to now.

Operators

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

Static Methods

deserialize(String data) Session
Creates a session from a JSON string.