Skip to main content

Module cookie_utils

Module cookie_utils 

Source
Expand description

Shared cookie utilities for building Set-Cookie headers.

Functions§

create_account_cookie_header
Render an account cookie with resolved account attributes and numeric TTL. Chunk names inherit the base cookie attributes.
create_clear_cookie
Build a Set-Cookie header value that clears an arbitrary cookie by name, using the session config’s cookie attributes for consistency.
create_clear_session_cookie
Build a Set-Cookie header value that clears the session cookie.
create_cookie
Build a Set-Cookie header value for an arbitrary cookie using the auth config’s session cookie attributes for consistency.
create_cookie_with_max_age
Create a factory cookie: producer attributes precede per-cookie overrides. Unlike session-token issuance, the configured family age takes precedence.
create_derived_session_cookie
Build a derived cookie with the resolved session-token attributes. Multiple-session proofs inherit the token’s overrides as well as defaults.
create_session_cookie
Build a Set-Cookie header value for a signed session token.
create_session_cookie_with_max_age
Build a Set-Cookie header value for a session token using the session cookie attributes, optionally omitting Max-Age to create a browser-session cookie.
create_session_like_cookie
Build a Set-Cookie header value using the session cookie attributes for an arbitrary cookie name.
delete_session_cookie_headers
Clear all cookies associated with the current session.
related_cookie_name
Build a Better Auth related cookie name using the configured session cookie prefix. For example, better-auth.session_token + session_data becomes better-auth.session_data.
sign_cookie_value
Sign and URI-encode a cookie value using Better Call’s HMAC-SHA256 encoding.
verify_cookie_value
Return a cookie’s payload only when its signature verifies.