Skip to content

getSession

Get item from sessionStorage.

Usage

js
import { getSession } from 'js-cool'

Signature

typescript
function getSession<T = any>(key: string): T | null

Parameters

ParameterTypeDescription
keystringKey to get

Returns

T | null - The value or null if not found/expired.

Examples

js
setSession('token', 'abc123', 1800)
getSession('token') // 'abc123'

// After expiration
getSession('token') // null

Released under the MIT License.