Reputation: 1121
I cannot find any information on setting the age of a cookie without using an external module. I know how to set the cookie but not its age and want to do it without the use of a library.
Any help would be much appreciated.
Upvotes: 1
Views: 682
Reputation: 10148
response.writeHead(200, {
'Set-Cookie':'sesh=wakadoo; expires='+new Date(new Date().getTime()+86409000).toUTCString()
});
This will set the expiry date of 1 day
for the cookie
Upvotes: 3
Reputation: 1546
//....
response.setHeader('Set-Cookie', ['type=ninja', 'language=javascript']);
//....
https://nodejs.org/api/http.html#http_response_setheader_name_value
Upvotes: 0