Nonflavored Prescription Medicine
    Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    sessions-pluspublic

    sessions-plus

    Sessions plus authentication module for Node.js

    What it does

    • Assigns a v4 UUID via cookie to each visitor
    • Creates a req.session object
    • All session data stored in req.session is loaded on visit for each visitor.

    That's about it.

    Hooking the session

    In order to hook the session into the user's req, you need to require the session-plus package:

    sessionsplus = require('sessions-plus');
    

    And then append the following at the very start of your createServer function:

    req = sessionsplus.start(req);
    if(req.session.cookieFresh == 'true'){
        res.setHeader('Set-Cookie', 'uuid=' + req.session.cookie);
        req.session.cookieFresh = 'false';
    }
    

    And append the following to the end of your createServer function:

    sessionsplus.end(req);
    

    Simple.

    Killing a session

    To wipe the contents of a session (IE: saved variables, login details, etc) you pass the req into the kill() function, like so:

    req = sessionsplus.kill(req);
    

    Keywords

    none

    install

    npm i sessions-plus

    Downloadsweekly downloads

    41

    version

    0.7.4

    license

    none

    last publish

    collaborators

    • avatar