mweibel / connect-session-sequelize

Sequelize SessionStore for Express/Connect

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"rolling" Option

vhmth opened this issue · comments

commented

When I set rolling to true in express-session, I notice that our app starts to get stuck in making infinite requests to our server. I'm not quite sure why this is. These are the options we're using for express-session:

{
  "secret": "some_secret",
  "resave": false,
  "saveUninitialized": false,
  "rolling": true,
  "cookie": {
    "domain": "www.testenv.com",
    "maxAge": 604800000
  }
}

And then for connect-session-sequelize:

{
  db: <some_db_handler>
  table: 'session'
}

I've tried all combos of saveUinitialized, rolling and resave and it seems like the issue fixes itself when rolling is removed. I've also tried set checkExpiration and expiration in the connect-session-sequelize options on top of the maxAge cookie option in express-session, but no cigar.

I will continue investigating, but I thought I'd open this in case someone has any idea what's going on.

I'm unsure of what the issue is. I'm surprised at how hard it's actually been to get production ready, scalable session management implemented with Express4.

On a side note, does accessing extended session data work for you? For example, req.session.userId? I have confirmed that my information is correctly being stored in the database, however I cannot seem to pull it out properly.

I have a session module defined as such:

sequelize_instance.define('user_session', { sid : { type : parent.Sequelize.STRING, primaryKey : true }, userId : parent.Sequelize.STRING, expires : parent.Sequelize.DATE, data : parent.Sequelize.STRING(50000) });

The data column stores JSON as text, for example:

{ "cookie":{"originalMaxAge":43200000,"expires":"2017-05-29T06:15:22.144Z","secure":true,"httpOnly":true,"domain":"airportme.me","path":"/"} ,"userId":2 }

and the userId column is being set correctly into the database as well. I am just confused now about accessing the extended data. Do I need to write queries to do this myself? Have you run into a problem like this before?

commented

@mdaronco yeah it's crazy. Sorry for the late reply - getting back to looking into this.

Have you tried to console.log req.session on a handler? Looking at get and set on the store here, it seems like it's saved/sync'd.

I'm going to dive into a rabbit hole looking at rolling. Will report back with findings.

commented

So I've been able to figure out that rolling is, indeed, working and that this is totally our fault in how we're handling cookie updates in the Loom extension. Closing.

@mdaronco I was able to see the data field of the sessions update properly.

image

Try running your server with DEBUG=expression-session,connect:session-sequelize set on the environment. This should log some info about what's going on with both the express-session and connect-session-sequelize moduels.