1.0.6 • Published 5 years ago
@sammylundqvist/sessionmanager v1.0.6
Session Manager - manages user sessions
Install
npm install @sammylundqvist/sessionmanager
Examples
Simple default - 32 char hash, cleans a user session after 15 min
const Session = require('@sammylundqvist/sessionmanager');
const session = new Session();
const key = session.createNewUserSession();
session.startInstance(); // continuously remove expired sessions
Validate user, the key is a sessionkey in string format
if (session.validateSession(key))
console.log("User is validated");
else
console.log("User is not validated ");
Functions
- startInstance() - starts active manager
- createNewUserSession() - creates a new user session, returns a session key
- endUserSession(key) - terminate session, returns true/false
- setSessionKeyLength(length) - how long the sessionkey should be
- setSessionExpire(min) - set when user session should expire
- validateSession(key) - validate user session, provide the key from the usercookie here