I'm using mongo-connect for storing my session data.this is my session config:
app.use(session({
secret: config.secureHasherKey ,
resave: false,
saveUninitialized: false ,
store: new MongoStore({ mongooseConnection: connection }) ,
cookie:{
secure: false ,
httpOnly: false ,
domain:'my.site.com' ,
path : ''
}
}));
It stored session perfectly but can not read it. this is my store database value:
{ "_id" : "ceF8BERpvE6O-M7l_rp_lL7D0tfMP8Mi", "session" : "{\"cookie\":{\"originalMaxAge\":null,\"expires\":null,\"secure\":false,\"httpOnly\":false,\"path\":\"/\"},\"auth\":\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsb2dlZEluIjp0cnVlLCJ1c2VybmFtZSI6InJlc2VsbGVyIiwiZW1haWwiOiJhc3AuMjA3M0BnbWFpbC5jb20iLCJfaWQiOiI1OGU2MmYxODY1YWZlNjQ1MzAxOTgzYjUiLCJpcCI6IjE4NS4xMi40NC4yNDgiLCJsYXN0bG9naW4iOiIxNDkyNjkyMDYzMDE3IiwiY3JlZGl0IjoxOTk5ODkxMjAsIm93bmVyX2lkIjoiNThlNjJmMTg2NWFmZTY0NTMwMTk4M2I1Iiwic3RhdHVzIjozLCJyb2xlIjo0LCJkbnMiOiJpcHR2LmlwdHZzdGFjay5jb20iLCJwcm92aWRlcl9pZCI6Imh0dHA6Ly8xMjcuMC4wLjE6MzcwMCIsInByb3ZpZGVyX2RvbWFpbiI6IjY0MDk2ODQ4NjQ5NDgwNDk0MDk0IiwiYnJhbmQiOlsiSVBUViBTdGFjayIsIkFsbCBDaGFubmVscyBFdmVyeSBXaGVyZSIsIjExMzItNXN0YXIucG5nIl0sImFjY2VzcyI6WzEsMiwzLDUsNywxMSwxMiwxMywxNywxOCwxOSwyMCwyMiw0MSw0Miw2Miw2Myw4MSw4MiwxMDEsMTAyLDEyMSwxMzEsMTMyLDEzNCwxNTEsMTUyLDE1MywxODEsMTgyLDE5MiwxOTMsMTk0LDE5NSwxOTYsMjkyLDMwMV0sImlhdCI6MTQ5MjY5MjA3MywiZXhwIjoxNDkyNzc4NDczfQ.qT65nZehOINNv_vzHtTawmUDCSEm2z-CcOrU75eq-7Q\"}", "expires" : ISODate("2017-05-04T12:40:56.621+0000") }
as you can see I have "auth" session in database but when I console.log it, It show me nothing like picture:
I found something new about my problem. When I set a session using background request, I can`t read that and when I set a session using a browser like a user workflow, I can read that.
How can I set a readable session by background request "request package in npm"?
via Sami Al Morshedi
No comments:
Post a Comment