expressjs / cookie-parser

Parse HTTP request cookies
MIT License
1.96k stars 220 forks source link

How to change/set domain, seems impossible? #56

Closed aebrs closed 5 years ago

aebrs commented 5 years ago

I don't know if it is a bug or question; Using Node.js/ Express/ cookie-parser, in back-end server sub-domain, I tried to set domain, but it seems impossible: 1- no effect:

server.use( cookieParser( 'sessionid', { name: 'session', domain: '.firouzeh-mfg.ir', maxAge: 24 60 60 * 1000 } ) )

2- This prevent even setting cookie: cookie not added to response

res.cookie('sessionid', req.userData.SessionId, { maxAge: settings.SESSION_TIME_OUT, httpOnly: true, domain:settings.COOKIE_DOMAIN});

3- This add cookie with defauld url:

res.cookie('idlang', req.userData.IdLang, { maxAge: settings.SESSION_TIME_OUT, httpOnly: true });

Is it a bug issue or bad coding? Thank you

dougwilson commented 5 years ago

I think there is a greater misunderstanding somewhere. This module does not take a domain option, or name option, or maxAge option (options are documented here https://github.com/expressjs/cookie-parser/blob/master/README.md#cookieparsersecret-options).

This module just

Parse Cookie header and populate req.cookies with an object keyed by the cookie names.