mpneuried / connect-redis-sessions

Session store using redis-sessions for Connect
MIT License
19 stars 8 forks source link

No cookie set with express 4.12.2 #11

Open unusualbob opened 9 years ago

unusualbob commented 9 years ago

This module looks promising due to it's support for deletion of all user sessions, but so far I have been unable to get a cookie via a simple GET request.

var express = require('express');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var ConnectRedisSessions = require('connect-redis-sessions');

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, 'public')));

app.use(cookieParser());
app.use(ConnectRedisSessions({'app':'test', cookie: {ttl: 10000}, debug:true}));

app.use('/', express.Router().get("/cookie", function(req, res, next) {
  res.render('index', { title: 'Express' });
}));

A GET request to localhost:3000/cookie results in no cookie set in the response. The debug in console says no SID found so run next. This works correctly in basically all the other session middlewares I've tried, but not this one.

Relevant versions: connect-redis-sessions@1.2.0 express-session@1.9.3 cookie-parser@1.3.4

Redis standalone server 2.8.19

mpneuried commented 9 years ago

i don't understand your issue. in my opinion it's working with the versions you described.

What are you expecting to happen? Do you just missed to call req.session.upgrade, witch will create a session and cookie?

I created a runnable to show you a working version of your code. http://runnable.com/VWvz-PcqEWAkkshG/connect-redis-session-issue-11-test-for-node-js-and-hello-world Can you describe the case in detail using this example?