1.0.6 • Published 5 years ago

@sammylundqvist/sessionmanager v1.0.6

Weekly downloads
1
License
ISC
Repository
-
Last release
5 years ago

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
1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago