{"action":"created","issue":{"url":"https://api.github.com/repos/expressjs/cookie-session/issues/83","repository_url":"https://api.github.com/repos/expressjs/cookie-session","labels_url":"https://api.github.com/repos/expressjs/cookie-session/issues/83/labels{/name}","comments_url":"https://api.github.com/repos/expressjs/cookie-session/issues/83/comments","events_url":"https://api.github.com/repos/expressjs/cookie-session/issues/83/events","html_url":"https://github.com/expressjs/cookie-session/issues/83","id":239934015,"number":83,"title":"New session on every request","user":{"login":"caseyryan","id":4113558,"avatar_url":"https://avatars1.githubusercontent.com/u/4113558?v=3","gravatar_id":"","url":"https://api.github.com/users/caseyryan","html_url":"https://github.com/caseyryan","followers_url":"https://api.github.com/users/caseyryan/followers","following_url":"https://api.github.com/users/caseyryan/following{/other_user}","gists_url":"https://api.github.com/users/caseyryan/gists{/gist_id}","starred_url":"https://api.github.com/users/caseyryan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caseyryan/subscriptions","organizations_url":"https://api.github.com/users/caseyryan/orgs","repos_url":"https://api.github.com/users/caseyryan/repos","events_url":"https://api.github.com/users/caseyryan/events{/privacy}","received_events_url":"https://api.github.com/users/caseyryan/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-07-01T07:35:28Z","updated_at":"2017-07-02T02:29:15Z","closed_at":"2017-07-02T01:13:32Z","body":"I've setup cookie-sessions exactly according to the instructions to test its work. But I get new session on every request:\r\nHere's the initialization code:\r\n```js\r\napp.use(cookieSession({\r\n    name: 'session',\r\n    keys: [Constants.COOKIE_SESSION_KEY_1, Constants.COOKIE_SESSION_KEY_2]\r\n}));\r\napp.use(function (req, res, next) {\r\n    req.sessionOptions.maxAge = 60000;\r\n    next();\r\n})\r\n```\r\n\r\nAnd here's the testing one:\r\n\r\n```js\r\nrouter.get('/auth', function(req, res, next) {\r\n\r\n    console.log(\"SESSION BEFORE:\", JSON.stringify( req.session), req.session.isNew);\r\n    res.json({ok: 'ok'})\r\n    req.session.test = 1;\r\n    console.log(\"SESSION AFTER:\", JSON.stringify(req.session));\r\n}\r\n```\r\nIt always gives me this output:\r\n\r\n> SESSION BEFORE: {} true\r\n> SESSION AFTER: {\"test\":1}\r\n\r\n\r\nI'm doing fetch() requests with credentials: 'include' option. \r\nI used client-sessions module before and it could set cookie\r\n\r\nAm I missing anything?"},"comment":{"url":"https://api.github.com/repos/expressjs/cookie-session/issues/comments/312466779","html_url":"https://github.com/expressjs/cookie-session/issues/83#issuecomment-312466779","issue_url":"https://api.github.com/repos/expressjs/cookie-session/issues/83","id":312466779,"user":{"login":"caseyryan","id":4113558,"avatar_url":"https://avatars1.githubusercontent.com/u/4113558?v=3","gravatar_id":"","url":"https://api.github.com/users/caseyryan","html_url":"https://github.com/caseyryan","followers_url":"https://api.github.com/users/caseyryan/followers","following_url":"https://api.github.com/users/caseyryan/following{/other_user}","gists_url":"https://api.github.com/users/caseyryan/gists{/gist_id}","starred_url":"https://api.github.com/users/caseyryan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caseyryan/subscriptions","organizations_url":"https://api.github.com/users/caseyryan/orgs","repos_url":"https://api.github.com/users/caseyryan/repos","events_url":"https://api.github.com/users/caseyryan/events{/privacy}","received_events_url":"https://api.github.com/users/caseyryan/received_events","type":"User","site_admin":false},"created_at":"2017-07-02T02:29:15Z","updated_at":"2017-07-02T02:29:15Z","body":"No no, sorry, my bad, i've just mistyped it here. It's definitely cookie-session. Not cookie-sessions.\r\nBut I found the problem already. It's because I finalized the response before the cookie was actually sent. I'm new to node.js and express, so I didn't know that red.json will end it as well. Cookie-session works fine :)"}}
{"actor":{"display_login":"caseyryan"}}