Session management backed by Datalevin.
Provides both direct session management functions and a Ring-compatible session store implementation.
Session management backed by Datalevin. Provides both direct session management functions and a Ring-compatible session store implementation.
(cleanup-expired-sessions! conn-or-system)Deletes expired sessions and returns the number removed.
Accepts a Datalevin connection or system map.
Deletes expired sessions and returns the number removed. Accepts a Datalevin connection or system map.
(cleanup-expired-sessions-tx db-or-conn-or-system)Creates transactions to delete all expired sessions.
Returns a vector of retraction transactions.
Creates transactions to delete all expired sessions. Returns a vector of retraction transactions.
(create-session user-ref
&
{:keys [expires-in-hours] :or {expires-in-hours 168}})Creates a new session for a user.
The user-ref can be either:
Options: :expires-in-hours - Session lifetime in hours (default 168 = 7 days)
Returns a map with :session-id and :tx (transaction data).
Note: The user must exist before creating a session.
Creates a new session for a user. The user-ref can be either: - A UUID (will be converted to lookup ref [:user/id uuid]) - A lookup ref like [:user/id uuid] - A numeric entity ID Options: :expires-in-hours - Session lifetime in hours (default 168 = 7 days) Returns a map with :session-id and :tx (transaction data). Note: The user must exist before creating a session.
(create-session-token session-id
{:keys [secret expires-in-sec]
:or {expires-in-sec 604800}})Creates a signed JWT token containing session data.
Options: :secret - Signing secret (required) :expires-in-sec - Token lifetime in seconds (default 604800 = 7 days)
Creates a signed JWT token containing session data. Options: :secret - Signing secret (required) :expires-in-sec - Token lifetime in seconds (default 604800 = 7 days)
(datalevin-session-store conn)(datalevin-session-store conn opts)Creates a Ring session store backed by Datalevin.
Options: :expires-in-hours - Session lifetime in hours (default 168 = 7 days)
Usage: (wrap-session handler {:store (datalevin-session-store conn)})
Creates a Ring session store backed by Datalevin.
Options:
:expires-in-hours - Session lifetime in hours (default 168 = 7 days)
Usage:
(wrap-session handler {:store (datalevin-session-store conn)})(delete-session-tx db-or-conn-or-system session-id)Creates a transaction to delete a session.
For Datalevin, this returns a retraction using the lookup ref. The session must exist for this to work.
Creates a transaction to delete a session. For Datalevin, this returns a retraction using the lookup ref. The session must exist for this to work.
(delete-user-sessions-tx db-or-conn-or-system user-id)Creates transactions to delete all sessions for a user.
Returns a vector of retraction transactions.
Creates transactions to delete all sessions for a user. Returns a vector of retraction transactions.
(get-session db-or-system session-id)Retrieves a session by ID.
Returns the session entity with user data if valid and not expired, nil otherwise.
Retrieves a session by ID. Returns the session entity with user data if valid and not expired, nil otherwise.
(get-session-user db-or-system session-id)Retrieves the user associated with a session.
Returns the user map if session is valid, nil otherwise.
Retrieves the user associated with a session. Returns the user map if session is valid, nil otherwise.
(update-session-store-conn store conn)Updates the connection used by a session store.
Useful when the connection changes during development.
Updates the connection used by a session store. Useful when the connection changes during development.
(verify-session-token token secret)Verifies and decodes a JWT session token.
Returns the session-id as UUID if valid, nil otherwise.
Verifies and decodes a JWT session token. Returns the session-id as UUID if valid, nil otherwise.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |