2

I am building an application with KrakenJS 1.0 and I do want to disable sessions.

In case you are wondering what I am doing that for: I really want to disable sessions for the sake of it. I do not want to have session handling. I do not want to have a session cookie. Nor anything else that remotely has to do with sessions.

I do not want my node process to waste a single cpu cycle on managing sessions when handling a request. I do not want a single byte of memory to be used for creating a session.

How can I disable sessions? By default kraken is creating a session with connect. How can I disable session management completely?

UPDATE

Right now I do req.session = null when handling a request. No session cookie is sent now. I do however think that Kraken still creates a session internally (though req.session = null destroys it immediately).

scravy
  • 11,904
  • 14
  • 72
  • 127

2 Answers2

2

By default, kraken sets up a session handler for you.

The easiest way to prevent that from happening by disabling that middleware in your app config. You can do so by adding something like the following into your config/config.js (or config/development.js for development-specific configs, etc):

{
    "middleware": {
        "session": {
            "enabled": false  
        }
    }
}
Jean-Charles
  • 366
  • 2
  • 11
2

Setting the session enabled to false will still init the Session middleware but a session is no longer created (evidenced by the lack of cookies). However you will still see the error about the Memory store being used. You can ignore that (unless you end up using a session). Doing this should work for most people that are running a session less config.

Just remember that in kraken config marking a middleware as "enabled": false will still add the middleware and run it once. Doing a "session": null will actually remove the middleware.

Trideep Gogoi
  • 179
  • 1
  • 4