Reputation: 93183
req.cookies :
When using cookie-parser middleware, this property is an object that contains cookies sent by the request. If the request contains no cookies, it defaults to {}.
// Cookie: name=tj req.cookies.name // => "tj"
This is what i found in the official documentation , However, it is expected that req.cookies.name
returns an object contains all info about cookie , Not ONLY STRING which is the value of cookie .
req.cookies.name ==> {value:"e3Lfdsd3pd1...er",expiration:...,..:...}
req.cookies.name ==> "e3Lfdsd3pd1...er"
How to retrieve other info of cookies than its value using request
object ?
Is there something ready in express
or cookie-parse
, Or have i to use Nodejs built-in API?
Upvotes: 2
Views: 934
Reputation: 3497
You can not access this data because it's simply not there.
The browser sends only the key-value pairs.
expires
and max-age
are local informations for the browser only and will not be committed to a web server in general.
You can set those attributes on cookie creation on the server, also you can overwrite them later (e.g. for invalidating), but I'm afraid you can't read the values of those attributes.
Upvotes: 2