You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In addition to providing a static object, you can also pass a callback function to dynamically generate the cookie options for each request. The callback receives the `req` object as its argument and should return an object containing the cookie settings.
53
+
54
+
```js
55
+
var app =express()
56
+
app.use(session({
57
+
secret:'keyboard cat',
58
+
resave:false,
59
+
saveUninitialized:true,
60
+
cookie:function(req) {
61
+
var match =req.url.match(/^\/([^/]+)/);
62
+
return {
63
+
path: match ?'/'+ match[1] :'/',
64
+
httpOnly:true,
65
+
secure:req.secure||false,
66
+
maxAge:60000
67
+
}
68
+
}
69
+
}))
70
+
```
71
+
52
72
The following are options that can be set in this object.
0 commit comments