Socket
Socket
Sign inDemoInstall

restify-session

Package Overview
Dependencies
92
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

restify-session

Session manager for REST server without cookies


Version published
Maintainers
1
Weekly downloads
21
decreased by-58%

Weekly downloads

Readme

Source

restify-session

This module is made to manage session without cookies in a REST server powered by restify. Please install Redis (>=2.0.0) in your server to enable this module. To create documentation you must install JSDuck and type in your terminal:

$ ./gen_doc.sh

Motivation

When you need to access to your REST server with session from a javascript app for iOS bundled as native app using Phonegap/Cordova, you can't use cookies because since iOS 5 these are disables by default.

Installation

Install restify-session as usual:

$ npm install --save restify-session

Usage

Is very simple to enable session:

// dependencies
var restify = require('restify'),
    session = require('restify-session')({
        debug : true,
        ttl   : 2
    });

// create the server
var server  = restify.createServer();

// attach the session manager
server.use(session.sessionManager)

// attach a route
server.get('/', function(req, res, next){
   res.send({ success: true, session: req.session });
   return next();
});

// start the server
server.listen(3000);

Save this file as server.js and start it in a terminal window:

$ node server.js

Open your browser and put the address of your server:

http://localhost:3000

Now you see an answer like this:

{"success":true,"session":{"sid":"ViS5pHE5n8McblTATbyFUJTGJyzVFeXOcAEZ41Zs"}}

You can see your session id (sid) into the response header:

Session-Id ViS5pHE5n8McblTATbyFUJTGJyzVFeXOcAEZ41Zs

See full documentation into doc folder.

Run Tests

All tests are written in mocha and designed to be run with npm:

$ npm test

Keywords

FAQs

Last updated on 31 Aug 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc