I upgraded the NodeJS app to version 4.0 and now I canβt set my own cookies in addition to the express session cookie. This problem only occurs the first time you request any session, when the user reloads the page where the user cookies are located.
var express = require('express'); var routes = require('./routes'); var http = require('http'); var path = require('path'); var session = require('express-session'); var app = express(); app.set('port', process.env.PORT || 3000); app.use(express.static(path.join(__dirname, 'public'))); app.use(require('body-parser')()); app.use(require('method-override')()); app.use(require('cookie-parser')('cookie-secret'));
To verify: 1. Run the above code, the test cookie will be sent to the browser correctly. 2. Then clear the cookies and uncomment the line "app.use (session ..."). 3. Launch the application and the only cookie is "sid". Where is the "testing"? 4. Reload the page (without clearing cookies) and there will be a "cookie" test.
It is important that all my cookies are on request.
source share