cookies cannot access from client












0














i'm trying to understand session and cookie using JS
i'm using express-session package to handle the session and cookie. The problem is from my client side, when i'm using postman the cookie appear



sessionID 92bda427-c9fd-4281-9979-a5b58b925e59
req.session Session {
cookie:
{ path: '/',
_expires: 2018-11-17T04:53:52.616Z,
originalMaxAge: 432000000,
httpOnly: false,
secure: false,
domain: 'localhost' },
__lastAccess: 1541998432616 }
req.cookies { SID: 's:92bda427-c9fd-4281-9979-
a5b58b925e59.gLHHBeXoebwvFEA3Y0d9kOwLxC6ICgkbcSPU9FMmHkQ'}


but when i'm using client to acces the same path, the cookie just return empty object, I already checked some stackoverflow question and some said to change the secure: false and httpOnly: false, but it didn't work for me



sessionID d5ec7773-fc1c-4aad-9dbb-6f822107a681
req.session Session {
cookie:
{ path: '/',
_expires: 2018-11-17T04:53:58.260Z,
originalMaxAge: 432000000,
httpOnly: false,
domain: 'localhost',
secure: false } }
req.cookies {}


my express setting



var express = require('express');
var cookieParser = require('cookie-parser');
var session = require('express-session');
var FileStore = require('session-file-store')(session);

var app = express();
app.use(cookieParser());
app.use(session({
genid: (req) => {
return uuid() // use UUIDs for session IDs
},
cookie: {
domain: 'localhost',
path: '/',
secure: false,
maxAge: 7 * 24 * 60 * 60 * 1000, // 7 days
httpOnly: false,
},
store: new FileStore(),
secret: 'some secret key',
name: 'SID',
resave: true,
saveUninitialized: true
}))









share|improve this question
























  • Please share your express cookie settings.
    – Suresh Prajapati
    Nov 12 '18 at 5:55










  • ok just added my express setting
    – Andrew
    Nov 12 '18 at 6:31










  • Can you see your cookie in the browser?
    – Suresh Prajapati
    Nov 12 '18 at 6:37










  • yes I can. it appear on the application - cookies - localhost section with the name and value
    – Andrew
    Nov 12 '18 at 6:41










  • Did u try xhr.withCredentials = true; in your request?
    – Suresh Prajapati
    Nov 12 '18 at 7:43
















0














i'm trying to understand session and cookie using JS
i'm using express-session package to handle the session and cookie. The problem is from my client side, when i'm using postman the cookie appear



sessionID 92bda427-c9fd-4281-9979-a5b58b925e59
req.session Session {
cookie:
{ path: '/',
_expires: 2018-11-17T04:53:52.616Z,
originalMaxAge: 432000000,
httpOnly: false,
secure: false,
domain: 'localhost' },
__lastAccess: 1541998432616 }
req.cookies { SID: 's:92bda427-c9fd-4281-9979-
a5b58b925e59.gLHHBeXoebwvFEA3Y0d9kOwLxC6ICgkbcSPU9FMmHkQ'}


but when i'm using client to acces the same path, the cookie just return empty object, I already checked some stackoverflow question and some said to change the secure: false and httpOnly: false, but it didn't work for me



sessionID d5ec7773-fc1c-4aad-9dbb-6f822107a681
req.session Session {
cookie:
{ path: '/',
_expires: 2018-11-17T04:53:58.260Z,
originalMaxAge: 432000000,
httpOnly: false,
domain: 'localhost',
secure: false } }
req.cookies {}


my express setting



var express = require('express');
var cookieParser = require('cookie-parser');
var session = require('express-session');
var FileStore = require('session-file-store')(session);

var app = express();
app.use(cookieParser());
app.use(session({
genid: (req) => {
return uuid() // use UUIDs for session IDs
},
cookie: {
domain: 'localhost',
path: '/',
secure: false,
maxAge: 7 * 24 * 60 * 60 * 1000, // 7 days
httpOnly: false,
},
store: new FileStore(),
secret: 'some secret key',
name: 'SID',
resave: true,
saveUninitialized: true
}))









share|improve this question
























  • Please share your express cookie settings.
    – Suresh Prajapati
    Nov 12 '18 at 5:55










  • ok just added my express setting
    – Andrew
    Nov 12 '18 at 6:31










  • Can you see your cookie in the browser?
    – Suresh Prajapati
    Nov 12 '18 at 6:37










  • yes I can. it appear on the application - cookies - localhost section with the name and value
    – Andrew
    Nov 12 '18 at 6:41










  • Did u try xhr.withCredentials = true; in your request?
    – Suresh Prajapati
    Nov 12 '18 at 7:43














0












0








0







i'm trying to understand session and cookie using JS
i'm using express-session package to handle the session and cookie. The problem is from my client side, when i'm using postman the cookie appear



sessionID 92bda427-c9fd-4281-9979-a5b58b925e59
req.session Session {
cookie:
{ path: '/',
_expires: 2018-11-17T04:53:52.616Z,
originalMaxAge: 432000000,
httpOnly: false,
secure: false,
domain: 'localhost' },
__lastAccess: 1541998432616 }
req.cookies { SID: 's:92bda427-c9fd-4281-9979-
a5b58b925e59.gLHHBeXoebwvFEA3Y0d9kOwLxC6ICgkbcSPU9FMmHkQ'}


but when i'm using client to acces the same path, the cookie just return empty object, I already checked some stackoverflow question and some said to change the secure: false and httpOnly: false, but it didn't work for me



sessionID d5ec7773-fc1c-4aad-9dbb-6f822107a681
req.session Session {
cookie:
{ path: '/',
_expires: 2018-11-17T04:53:58.260Z,
originalMaxAge: 432000000,
httpOnly: false,
domain: 'localhost',
secure: false } }
req.cookies {}


my express setting



var express = require('express');
var cookieParser = require('cookie-parser');
var session = require('express-session');
var FileStore = require('session-file-store')(session);

var app = express();
app.use(cookieParser());
app.use(session({
genid: (req) => {
return uuid() // use UUIDs for session IDs
},
cookie: {
domain: 'localhost',
path: '/',
secure: false,
maxAge: 7 * 24 * 60 * 60 * 1000, // 7 days
httpOnly: false,
},
store: new FileStore(),
secret: 'some secret key',
name: 'SID',
resave: true,
saveUninitialized: true
}))









share|improve this question















i'm trying to understand session and cookie using JS
i'm using express-session package to handle the session and cookie. The problem is from my client side, when i'm using postman the cookie appear



sessionID 92bda427-c9fd-4281-9979-a5b58b925e59
req.session Session {
cookie:
{ path: '/',
_expires: 2018-11-17T04:53:52.616Z,
originalMaxAge: 432000000,
httpOnly: false,
secure: false,
domain: 'localhost' },
__lastAccess: 1541998432616 }
req.cookies { SID: 's:92bda427-c9fd-4281-9979-
a5b58b925e59.gLHHBeXoebwvFEA3Y0d9kOwLxC6ICgkbcSPU9FMmHkQ'}


but when i'm using client to acces the same path, the cookie just return empty object, I already checked some stackoverflow question and some said to change the secure: false and httpOnly: false, but it didn't work for me



sessionID d5ec7773-fc1c-4aad-9dbb-6f822107a681
req.session Session {
cookie:
{ path: '/',
_expires: 2018-11-17T04:53:58.260Z,
originalMaxAge: 432000000,
httpOnly: false,
domain: 'localhost',
secure: false } }
req.cookies {}


my express setting



var express = require('express');
var cookieParser = require('cookie-parser');
var session = require('express-session');
var FileStore = require('session-file-store')(session);

var app = express();
app.use(cookieParser());
app.use(session({
genid: (req) => {
return uuid() // use UUIDs for session IDs
},
cookie: {
domain: 'localhost',
path: '/',
secure: false,
maxAge: 7 * 24 * 60 * 60 * 1000, // 7 days
httpOnly: false,
},
store: new FileStore(),
secret: 'some secret key',
name: 'SID',
resave: true,
saveUninitialized: true
}))






node.js reactjs express cookies session-cookies






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 '18 at 6:34

























asked Nov 12 '18 at 5:01









Andrew

123




123












  • Please share your express cookie settings.
    – Suresh Prajapati
    Nov 12 '18 at 5:55










  • ok just added my express setting
    – Andrew
    Nov 12 '18 at 6:31










  • Can you see your cookie in the browser?
    – Suresh Prajapati
    Nov 12 '18 at 6:37










  • yes I can. it appear on the application - cookies - localhost section with the name and value
    – Andrew
    Nov 12 '18 at 6:41










  • Did u try xhr.withCredentials = true; in your request?
    – Suresh Prajapati
    Nov 12 '18 at 7:43


















  • Please share your express cookie settings.
    – Suresh Prajapati
    Nov 12 '18 at 5:55










  • ok just added my express setting
    – Andrew
    Nov 12 '18 at 6:31










  • Can you see your cookie in the browser?
    – Suresh Prajapati
    Nov 12 '18 at 6:37










  • yes I can. it appear on the application - cookies - localhost section with the name and value
    – Andrew
    Nov 12 '18 at 6:41










  • Did u try xhr.withCredentials = true; in your request?
    – Suresh Prajapati
    Nov 12 '18 at 7:43
















Please share your express cookie settings.
– Suresh Prajapati
Nov 12 '18 at 5:55




Please share your express cookie settings.
– Suresh Prajapati
Nov 12 '18 at 5:55












ok just added my express setting
– Andrew
Nov 12 '18 at 6:31




ok just added my express setting
– Andrew
Nov 12 '18 at 6:31












Can you see your cookie in the browser?
– Suresh Prajapati
Nov 12 '18 at 6:37




Can you see your cookie in the browser?
– Suresh Prajapati
Nov 12 '18 at 6:37












yes I can. it appear on the application - cookies - localhost section with the name and value
– Andrew
Nov 12 '18 at 6:41




yes I can. it appear on the application - cookies - localhost section with the name and value
– Andrew
Nov 12 '18 at 6:41












Did u try xhr.withCredentials = true; in your request?
– Suresh Prajapati
Nov 12 '18 at 7:43




Did u try xhr.withCredentials = true; in your request?
– Suresh Prajapati
Nov 12 '18 at 7:43












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53256191%2fcookies-cannot-access-from-client%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53256191%2fcookies-cannot-access-from-client%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Full-time equivalent

さくらももこ

13 indicted, 8 arrested in Calif. drug cartel investigation