Skip to content

Commit d2795c6

Browse files
committed
update doc
1 parent 552f3d6 commit d2795c6

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

Diff for: README.md

+7-17
Original file line numberDiff line numberDiff line change
@@ -280,36 +280,26 @@ The default value is `'keep'`.
280280
- `'keep'` The session in the store will be kept, but modifications made during
281281
the request are ignored and not saved.
282282

283-
##### getcookie
284283

285-
Allows to specify a custom function to read and parse the cookie.
284+
##### getcookie, setcookie
286285

287-
Warning the function signature is subject to change in the future, this option is unsafe
286+
Allows to specify custom functions to parse and set cookies.
287+
288+
Warnings:
289+
- cookies must be parsed accordingly to how they are set of course
290+
- the function signatures are subject to change in the future
288291

289292
```js
290293
app.use(session({
291294
getcookie(req) { // full signature is (req, name, secrets)
292295
var cookies = cookie.parse(headers.cookie || headers.authorization || '');
293296
return signature.unsign(cookies[sessionKey] || '', sessionSecret);
294297
},
295-
secret: 'keyboard cat'
296-
}))
297-
```
298-
299-
300-
##### setcookie
301-
302-
Similarly to getookie, it allows to specify a custom function to set cookie.
303-
304-
Warning again, the function signature is subject to change in the future,
305-
and should be used carefully like getcookie
306-
307-
```js
308-
app.use(session({
309298
setcookie(res, name, val, secret, options) {
310299
var signed = signature.sign(val, secret);
311300
var data = cookie.serialize(name, signed, options);
312301
res.setHeader('set-cookie', data);
302+
res.setHeader('Access-Control-Expose-Headers', 'Authorization');
313303
res.setHeader('authorization', data);
314304
},
315305
secret: 'keyboard cat'

0 commit comments

Comments
 (0)