# session **Repository Path**: mirrors_WebReflection/session ## Basic Information - **Project Name**: session - **Description**: A unique session per tab idenfitier. - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-09-25 - **Last Updated**: 2025-12-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # @webreflection/session A unique session per tab idenfitier, able to set a unique per-tab cookie representing the lifecycle of the same tab *sessionStorage*. **[Live Demo](https://webreflection.github.io/session/)** ```js import { cookie, storage, session } from 'https://esm.run/@webreflection/session'; // Cookie: my-session-name=UNIQUE-RANDOM-IDENTIFIER session('my-session-name', { domain: location.hostname, // secret: true | false, // expires: ... and all other cookies entries // except for `name` and `value` onchange({ type: string, value: string }) { // your logic here } }); ``` ### onchange({ type, value }) * `type` is **new** whenever the tab was newly created * `type` is **old** whenever the tab was just refreshed * `type` is **visible** whenever the tab went from *hidden* to *visible* * `type` is **unload** whenever the tab is being closed (or reloaded) * `value` is always a unique identifier for the current tab and the value of the cookie under the chosen `name` initializator