Skip to main content

generateSessionId()

generateSessionId generates a unique session identifier string. Use this utility to create a new session ID when a user signs in and store the value in a cookie or server-side session store.

Signature

generateSessionId(): string

Returns

string — A unique session identifier composed of a timestamp-based prefix and a random suffix, encoded in base-36.

Usage

src/routes/sign-in.ts
import { generateSessionId, CookieConfig, getSessionCookieOptions } from '@thunderid/node'

app.get('/sign-in', (req, res) => {
const sessionId = generateSessionId()

res.cookie(
CookieConfig.SESSION_COOKIE_NAME,
sessionId,
getSessionCookieOptions({ maxAge: 3600 }),
)

auth.signIn(
(authUrl) => res.redirect(authUrl),
sessionId,
)
})
ThunderID LogoThunderID Logo

Product

DocsAPIsSDKs
© WSO2 LLC. All rights reserved.Privacy PolicyCookie Policy