How to use the cookies.connect function in cookies

To help you get started, we’ve selected a few cookies 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 punkave / knowtify / server.js View on Github external
var port = process.env.PORT || 5000

var secretKeys = process.env.SECRET ? process.env.SECRET.split(' ') : []
var keys = keygrip(secretKeys)

var redisUrl = process.env.REDISTOGO_URL && url.parse(process.env.REDISTOGO_URL)
var redisOptions = redisUrl && {
  port: redisUrl.port, 
  host: redisUrl.hostname, 
  auth: redisUrl.auth.split(':')[1]
}
RedSess.createClient(redisOptions)

http.createServer(stack(
  cookies.connect(keys),
  redsess,
  rend,
  router
)).listen(port, function() {
  console.log('Listening on '+port)
})

function redsess(req, res, next) {
  req.session = res.session = new RedSess(req, res)
  next()
}

function rend(req, res, next) {
  res.context = {}
  res.render = function(filename) {
    fs.readFile('templates/'+filename, function(err, template) {