Open
Conversation
2 similar comments
Contributor
|
There's logic in Lines 290 to 307 in 10bb122
const ONE_DAY = 24 * 60 * 60 * 1000; |
Author
|
@jmitchell38488 yes but Lines 241 to 250 in 10bb122 plus my screenshot clearly shows that session's max age is not set. |
Contributor
|
What's your option config? |
Author
|
@jmitchell38488 there's no config. why don't you just try it for yourself and see |
Author
|
setup import Koa from 'koa'
import { aqt } from 'rqt'
import session from 'koa-session'
const koa = new Koa()
const s = session(koa, {
signed: false,
})
koa.use(s)
koa.use((ctx, next) => {
if (ctx.path == '/max-age') {
ctx.session.maxAge = 60 * 60 * 1000
}
if (ctx.path == '/confirm') {
ctx.session.user = 'update'
} else {
ctx.session.user = 'hello'
}
ctx.body = '# ' + ctx.path
})test koa.listen(async function() {
const a = 'http://localhost:' + this.address().port
let res
res = await aqt(a)
log(res)
res = await aqt(a + '/max-age')
const { headers: { 'set-cookie': setCookie } } = res
log(res)
res = await aqt(a + '/test', {
headers: { cookie: setCookie },
})
// console.log(res)
log(res)
res = await aqt(a + '/confirm')
log(res)
this.close()
})
const log = (res) => {
const { body, headers: { 'set-cookie': cookie = [] } } = res
console.log(body)
console.log(cookie.map(s => s.split('; ').join('\n ')).join('\n'))
}output
# /
koa:sess=eyJ1c2VyIjoiaGVsbG8iLCJfZXhwaXJlIjoxNTc3MDY4Nzk1NjA5LCJfbWF4QWdlIjo4NjQwMDAwMH0=
path=/
httponly
# /max-age
koa:sess=eyJ1c2VyIjoiaGVsbG8iLCJfZXhwaXJlIjoxNTc2OTg1OTk1NjcyLCJfbWF4QWdlIjozNjAwMDAwfQ==
path=/
expires=Sun, 22 Dec 2019 03:39:55 GMT
httponly
# /test
# /confirm
koa:sess=eyJ1c2VyIjoidXBkYXRlIiwiX2V4cGlyZSI6MTU3NzA2ODc5NTY5NCwiX21heEFnZSI6ODY0MDAwMDB9
path=/
httponly |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The initial cookie that this middleware drops does not have
expires, becausemaxAgeis never set in properties. It is only set later when decoding the cookie, and only if it has been updated, therefore if no data was updated, the cookie is always limited to the session.