{"action":"created","issue":{"url":"https://api.github.com/repos/expressjs/session/issues/371","repository_url":"https://api.github.com/repos/expressjs/session","labels_url":"https://api.github.com/repos/expressjs/session/issues/371/labels{/name}","comments_url":"https://api.github.com/repos/expressjs/session/issues/371/comments","events_url":"https://api.github.com/repos/expressjs/session/issues/371/events","html_url":"https://github.com/expressjs/session/issues/371","id":183105234,"number":371,"title":"session doesn't save","user":{"login":"hich-em","id":6135555,"avatar_url":"https://avatars.githubusercontent.com/u/6135555?v=3","gravatar_id":"","url":"https://api.github.com/users/hich-em","html_url":"https://github.com/hich-em","followers_url":"https://api.github.com/users/hich-em/followers","following_url":"https://api.github.com/users/hich-em/following{/other_user}","gists_url":"https://api.github.com/users/hich-em/gists{/gist_id}","starred_url":"https://api.github.com/users/hich-em/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hich-em/subscriptions","organizations_url":"https://api.github.com/users/hich-em/orgs","repos_url":"https://api.github.com/users/hich-em/repos","events_url":"https://api.github.com/users/hich-em/events{/privacy}","received_events_url":"https://api.github.com/users/hich-em/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/expressjs/session/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-10-14T17:21:58Z","updated_at":"2016-10-14T17:37:09Z","closed_at":null,"body":"```\r\napp.use(cookieParser());\r\napp.use(session({\r\n    secret: 'keyboard cat',\r\n    resave: false,\r\n    saveUninitialized: true,\r\n    cookie: {\r\n        secure: false\r\n    }\r\n}))\r\n```\r\n\r\n```\r\napp.post('/login', (req, res) => {\r\n    let user = Users.findOne({\r\n        username: req.body.username,\r\n        password: req.body.password\r\n    }, function(err, doc) {\r\n        console.log(err, doc);\r\n        if (doc && doc._id) {\r\n//here changing of the session\r\n            req.session.user = doc;\r\n            req.session.save((err) => {\r\n                if (!err) {\r\n                    console.log(req.session);\r\n                    res.redirect(\"/\");\r\n                }\r\n            });\r\n        }\r\n    });\r\n    //console.log(req.session);\r\n});\r\n```\r\n\r\n```\r\napp.use(function(req, res, next) {\r\n    console.log(req.session);//here it log the session without the user\r\n    if (req.path === \"/login\" || req.path === \"/register\" || req.path === \"/registerUser\" || req.path === \"/instagram/registerUser\" || (req.session && req.session.user)) {\r\n        next();\r\n    } else {\r\n        res.redirect(\"/login\");\r\n    }\r\n});\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/expressjs/session/issues/comments/253869495","html_url":"https://github.com/expressjs/session/issues/371#issuecomment-253869495","issue_url":"https://api.github.com/repos/expressjs/session/issues/371","id":253869495,"user":{"login":"gabeio","id":643410,"avatar_url":"https://avatars.githubusercontent.com/u/643410?v=3","gravatar_id":"","url":"https://api.github.com/users/gabeio","html_url":"https://github.com/gabeio","followers_url":"https://api.github.com/users/gabeio/followers","following_url":"https://api.github.com/users/gabeio/following{/other_user}","gists_url":"https://api.github.com/users/gabeio/gists{/gist_id}","starred_url":"https://api.github.com/users/gabeio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gabeio/subscriptions","organizations_url":"https://api.github.com/users/gabeio/orgs","repos_url":"https://api.github.com/users/gabeio/repos","events_url":"https://api.github.com/users/gabeio/events{/privacy}","received_events_url":"https://api.github.com/users/gabeio/received_events","type":"User","site_admin":false},"created_at":"2016-10-14T17:37:09Z","updated_at":"2016-10-14T17:37:09Z","body":"see #360."}}
{"actor":{"display_login":"gabeio"}}