Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A hapi cookie jar

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
images
lib
test
.gitignore
.travis.yml
LICENSE
Makefile
README.md
index.js
package.json

README.md

yar Logo

A hapi cookie jar

Build Status

The yar plugin adds a simple was to set a persistant state (using an Iron encrypted cookie) across requests. It is not designed for session management but to supplement an active session with transactional information.

For example, the first handler sets the jar content and the second utilizes it:

var handler1 = function () {

    this.plugins.yar = {
        key: 'value'
    };

    return this.reply();
};

var handler2 = function () {

    this.reply(this.state.yar.key);     // Will send back 'value'
};

The plugin requires a password for encryption, and the ext permission:

var options = {
    permissions: {
        ext: true                   // Required
    },
    plugin: {
        name: 'yar' ,               // Optional, overrides cookie name. Defaults to 'yar'. Doesn't affect 'plugins.yar'.
        isSingleUse: false,         // Optional, clears jar after one request. Defaults to false.
        options: {
            password: 'password',   // Required
            isSecure: true          // Optional, any supported cookie options except `encoding`
        }
    }
};

var server = new Hapi.Server();

server.plugin().require('yar', options, function (err) { });
Something went wrong with that request. Please try again.