How to use the express-session.Cookie function in express-session

To help you get started, we’ve selected a few express-session examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jdesboeufs / connect-mongo / test / legacy-tests.js View on Github external
const makeCookie = function() {
  const cookie = new expressSession.Cookie()
  cookie.maxAge = 10000 // This sets cookie.expire through a setter
  cookie.secure = true
  cookie.domain = 'cow.com'

  return cookie
}
github tencentyun / wafer-node-session / index.js View on Github external
response.json({ type, message });
                response.end();
                return;
            }

            const { sessionKey, openId } = yield login({ appId, appSecret, code });

            const wxBiz = new WXBizDataCrypt(appId, sessionKey);
            const userInfo = wxBiz.decryptData(encryptData, iv);

            const session = request.session = {};
            session.id = request.sessionID = crypto.randomBytes(32).toString('hex');
            session.skey = generateSkey(sessionKey);
            session.sessionKey = sessionKey;
            session.userInfo = userInfo;
            session.cookie = new Cookie({ maxAge }); // fake cookie to support express-session Stores

            // save the session
            store.set(session.id, session, (err) => {
                if (err) {
                    console.error('store.set() error: ', err);
                }
                response.json({
                    [constants.WX_SESSION_MAGIC_ID]: 1,
                    session: {
                        id: session.id,
                        skey: session.skey
                    }
                });
                response.end();
            });
            return;
github senchalabs / connect / lib / middleware / cookieSession.js View on Github external
return function cookieSession(req, res, next) {

    // req.secret is for backwards compatibility
    var secret = options.secret || req.secret;
    if (!secret) throw new Error('`secret` option required for cookie sessions');

    // default session
    req.session = {};
    var cookie = req.session.cookie = new Cookie(options.cookie);

    // pathname mismatch
    var originalPath = parseUrl.original(req).pathname;
    if (0 != originalPath.indexOf(cookie.path)) return next();

    // cookieParser secret
    if (!options.secret && req.secret) {
      req.session = req.signedCookies[key] || {};
      req.session.cookie = cookie;
    } else {
      // TODO: refactor
      var rawCookie = req.cookies[key];
      if (rawCookie) {
        var unsigned = cookieParser.signedCookie(rawCookie, secret);
        if (unsigned) {
          var original = unsigned;
github tjanczuk / iisnode / src / iisnode / node-inspector-0.7.3 / node_modules / node-inspector / node_modules / connect / lib / middleware / cookieSession.js View on Github external
return function cookieSession(req, res, next) {

    // req.secret is for backwards compatibility
    var secret = options.secret || req.secret;
    if (!secret) throw new Error('`secret` option required for cookie sessions');

    // default session
    req.session = {};
    var cookie = req.session.cookie = new Cookie(options.cookie);

    // pathname mismatch
    var originalPath = url.parse(req.originalUrl).pathname;
    if (0 != originalPath.indexOf(cookie.path)) return next();

    // cookieParser secret
    if (!options.secret && req.secret) {
      req.session = req.signedCookies[key] || {};
      req.session.cookie = cookie;
    } else {
      // TODO: refactor
      var rawCookie = req.cookies[key];
      if (rawCookie) {
        var unsigned = utils.parseSignedCookie(rawCookie, secret);
        if (unsigned) {
          var original = unsigned;
github jonniespratley / jps-passbook-manager / node_modules / grunt-contrib-connect / node_modules / connect / lib / middleware / cookieSession.js View on Github external
return function cookieSession(req, res, next) {

    // req.secret is for backwards compatibility
    var secret = options.secret || req.secret;
    if (!secret) throw new Error('`secret` option required for cookie sessions');

    // default session
    req.session = {};
    var cookie = req.session.cookie = new Cookie(options.cookie);

    // pathname mismatch
    var originalPath = parseUrl.original(req).pathname;
    if (0 != originalPath.indexOf(cookie.path)) return next();

    // cookieParser secret
    if (!options.secret && req.secret) {
      req.session = req.signedCookies[key] || {};
      req.session.cookie = cookie;
    } else {
      // TODO: refactor
      var rawCookie = req.cookies[key];
      if (rawCookie) {
        var unsigned = cookieParser.signedCookie(rawCookie, secret);
        if (unsigned) {
          var original = unsigned;
github ifgyong / demo / React-native / Helloword / node_modules / connect / lib / middleware / cookieSession.js View on Github external
return function cookieSession(req, res, next) {

        // req.secret is for backwards compatibility
        var secret = options.secret || req.secret;
        if (!secret) throw new Error('`secret` option required for cookie sessions');

        // default session
        req.session = {};
        var cookie = req.session.cookie = new Cookie(options.cookie);

        // pathname mismatch
        var originalPath = parseUrl.original(req).pathname;
        if (0 != originalPath.indexOf(cookie.path)) return next();

        // cookieParser secret
        if (!options.secret && req.secret) {
            req.session = req.signedCookies[key] || {};
            req.session.cookie = cookie;
        } else {
            // TODO: refactor
            var rawCookie = req.cookies[key];
            if (rawCookie) {
                var unsigned = cookieParser.signedCookie(rawCookie, secret);
                if (unsigned) {
                    var original = unsigned;
github skepticfx / domstorm / node_modules / express / node_modules / connect / lib / middleware / cookieSession.js View on Github external
return function cookieSession(req, res, next) {

    // req.secret is for backwards compatibility
    var secret = options.secret || req.secret;
    if (!secret) throw new Error('`secret` option required for cookie sessions');

    // default session
    req.session = {};
    var cookie = req.session.cookie = new Cookie(options.cookie);

    // pathname mismatch
    var originalPath = url.parse(req.originalUrl).pathname;
    if (0 != originalPath.indexOf(cookie.path)) return next();

    // cookieParser secret
    if (!options.secret && req.secret) {
      req.session = req.signedCookies[key] || {};
      req.session.cookie = cookie;
    } else {
      // TODO: refactor
      var rawCookie = req.cookies[key];
      if (rawCookie) {
        var unsigned = utils.parseSignedCookie(rawCookie, secret);
        if (unsigned) {
          var original = unsigned;
github MaximeHeckel / HarborJS / node_modules / express / node_modules / connect / lib / middleware / cookieSession.js View on Github external
return function cookieSession(req, res, next) {

    // req.secret is for backwards compatibility
    var secret = options.secret || req.secret;
    if (!secret) throw new Error('`secret` option required for cookie sessions');

    // default session
    req.session = {};
    var cookie = req.session.cookie = new Cookie(options.cookie);

    // pathname mismatch
    var originalPath = url.parse(req.originalUrl).pathname;
    if (0 != originalPath.indexOf(cookie.path)) return next();

    // cookieParser secret
    if (!options.secret && req.secret) {
      req.session = req.signedCookies[key] || {};
      req.session.cookie = cookie;
    } else {
      // TODO: refactor
      var rawCookie = req.cookies[key];
      if (rawCookie) {
        var unsigned = utils.parseSignedCookie(rawCookie, secret);
        if (unsigned) {
          var original = unsigned;
github nodesocket / quote-stream / node_modules / express / node_modules / connect / lib / middleware / cookieSession.js View on Github external
return function cookieSession(req, res, next) {

    // req.secret is for backwards compatibility
    var secret = options.secret || req.secret;
    if (!secret) throw new Error('`secret` option required for cookie sessions');

    // default session
    req.session = {};
    var cookie = req.session.cookie = new Cookie(options.cookie);

    // pathname mismatch
    var originalPath = parseUrl.original(req).pathname;
    if (0 != originalPath.indexOf(cookie.path)) return next();

    // cookieParser secret
    if (!options.secret && req.secret) {
      req.session = req.signedCookies[key] || {};
      req.session.cookie = cookie;
    } else {
      // TODO: refactor
      var rawCookie = req.cookies[key];
      if (rawCookie) {
        var unsigned = cookieParser.signedCookie(rawCookie, secret);
        if (unsigned) {
          var original = unsigned;