Skip to content

A client-side session manager, manage access token, user data and session time.

Notifications You must be signed in to change notification settings

maikkkko1/js-clientside-session-manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

Javascript client-side session manager

A client-side session manager, manage access token, user data and session time.

Getting started

npm i clientside-session-manager

Import the module.

import SessionManager from 'clientside-session-manager';

And then the session manager methods will be available.

Examples:

Creates a session that will expires in 30 minutes.

SessionManager.create('randomaccesstoken', {name: 'Maikon', age: 23}, 30)

Accesses the token from the created session.

const token = SessionManager.getToken();

Accesses the name attribute from the created session.

const name = SessionManager.getDetail('name');

All available methods.

create(token, data, timeExpire) - // Creates a session.
getAll() - // Returns the full user data object.
getDetail(detailKey) - // Returns a unique information from user data.
getToken() - // Returns the access token.
exists() - // Returns whether a valid session exists.
updateToken(newToken) - // Updates the access token and when the session will expire.
updateDetail(detailKey, newValue) - // Updates a unique information in user data.
addDetail(detailKey, value) - // Add a new information in user data.
destroy(reloadPage) - // Destroys the current active session.

About

A client-side session manager, manage access token, user data and session time.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published