Cookie Utilities
General-purpose cookie management functions.cookieUtils.setCookie
Set a cookie with the given name, value, and options.The cookie name
The cookie value
Cookie configuration options
CookieOptions
Expiration date (Date object) or number of days until expiration
Maximum age in seconds
Cookie domain
Cookie path
Whether cookie requires HTTPS
SameSite cookie attribute
Whether cookie is HTTP-only (not accessible via JavaScript)
cookieUtils.getCookie
Get a cookie value by name.The cookie name to retrieve
string | null - The cookie value, or null if not found
Example:
cookieUtils.removeCookie
Remove a cookie by name.The cookie name to remove
Cookie removal options (domain and path must match the original cookie)
RemoveCookieOptions
Cookie domain (must match original)
Cookie path (must match original)
JWT Token Utilities
Specialized utilities for managing JWT authentication tokens.jwtCookieUtils.saveToken
Save a JWT token to a secure cookie.The JWT token to save
- Name:
logto_authtoken - Expires: 7 days
- Secure: true (HTTPS only)
- SameSite: strict
- Path: /
jwtCookieUtils.getToken
Retrieve the JWT token from the cookie.string | null - The JWT token, or null if not found
Example:
jwtCookieUtils.removeToken
Remove the JWT token cookie.Configuration Validation
validateLogtoConfig
Validate Logto configuration for required fields.The Logto configuration object to validate
Error if configuration is invalid or missing required fields
Example:
The library uses internal utilities for transforming user data and generating guest IDs. These utilities are used automatically by the AuthProvider and do not need to be called directly.