code: function getcookie(req, name, secrets) {
    var header = req.headers.cookie;
    var raw;
    var val;
  
    // read from cookie header
    if (header) {
      var cookies = cookie.parse(header);
  
      raw = cookies[name];
  
      if (raw) {
        if (raw.substr(0, 2) === 's:') {
          val = unsigncookie(raw.slice(2), secrets);
  
          if (val === false) {
            debug('cookie signature invalid');
            val = undefined;
          }
        } else {
          debug('cookie unsigned')
        }
      }
    }
  
    // back-compat read from cookieParser() signedCookies data
    if (!val && req.signedCookies) {
      val = req.signedCookies[name];
    }
  
    // back-compat read from cookieParser() cookies data
    if (!val && req.cookies) {
      raw = req.cookies[name];
  
      if (raw) {
        if (raw.substr(0, 2) === 's:') {
          val = unsigncookie(raw.slice(2), secrets);
  
          if (val === false) {
            debug('cookie signature invalid');
            val = undefined;
          }
        } else {
          debug('cookie unsigned')
        }
      }
    }
  
    return val;
  }
docs: https://github.com/expressjs/session/blob/master/index.js#L486