Session 🔌
Provides working with sessions
Note:
Uses a cookies for working with sessions
Procs
proc genSessionId(): string {....raises: [], tags: [], forbids: [].}
-
Generates unique session ID like hpxs_sndjKgij1n2niug9uDbdfVkn9er8Gh3n
Example:
echo genSessionId()
proc getSession(req: Request; host: string; cookies: var seq[string]; timeout: int64 = 0): Session {....gcsafe, inline, ...raises: [KeyError], tags: [TimeEffect], forbids: [].}
-
Gets or creates a new session.
If session is exists and timeout is not expired then returns this session.
Creates a new session with timeout in other case.
Templates
template closeSession(session: Session)
-
Closes actove session
See also closeSession template
template closeSession(sessionId: string)
-
Closes active session
See also closeSession template
template startSession(): Session
-
Starts a new session or returns created if exists
See also startSession template
template startSession(timeout: int64): Session
-
Starts a new session with timeout or returns created if exists or timeout is not expired
See also startSession template