all files / express-stormpath/lib/helpers/ set-temp-cookie.js

100% Statements 4/4
50% Branches 1/2
100% Functions 1/1
100% Lines 4/4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24                          12× 12×     12×          
'use strict';
 
/**
 * Set a temporary cookie that is only accessible server-side.
 *
 * @method
 * @private
 *
 * @param {Object} res - The http response.
 * @param {string} name - The name of the cookie.
 * @param {string} name - The value of the cookie.
 * @param {string} maxAge - The max number of seconds the cookie is allowed to live.
 */
module.exports = function (res, name, value, maxAge) {
  Eif (maxAge === undefined) {
    maxAge = 60 * 5;
  }
 
  res.cookie(name, value, {
    maxAge: maxAge * 1000,
    httpOnly: true
  });
};