Slide 21
Slide 21 text
handler:cookie
app.all(‘/setcookie’, function(req, res, next) {
res.cookie(‘name’, ‘tobi’, {
domain: ‘.example.com’
, path: ‘/admin’
, secure: true
, expires: new Date(Date.now() + 900000)
, httpOnly: true
});
});
domain => client-side可以存取該cookie的domain
path => 哪個URL的請求會帶此cookie 如果為/ 為全域cookie
secure => HTTPS only
expires => 何時到期
httpOnly => client-side無法讀取