ttl always gets millisecond value when session expiry is set
arfeen opened this issue · comments
Arfeen commented
ttl
is getting a wrong value (or actually millisecond value) when session expiry is already set.
Take a look at this
if (!this.disableTTL) {
ttl = this._getTTL(sess)
args.push("EX", ttl)
}
"EX" expects the seconds value not the millisecond, but then see the this._getTTL(sess)
:
if (sess && sess.cookie && sess.cookie.expires) {
let ms = Number(new Date(sess.cookie.expires)) - Date.now()
ttl = Math.ceil(ms / 1000)
} else {
ttl = this.ttl
}
I believe this should not divide by 1000 since later it will be stored with "EX" argument in Redis .
Please correct me, but I feel that is a bug.
Micael Levi L. Cavalcante commented
- the docs saids
ttl
is the time in seconds. Thus I believe_getTTL
should return the time in seconds ms / 1000
is there to convert from milliseconds to seconds (as expected byEX
)
I didn't get what's wrong
Arfeen commented
- the docs saids
ttl
is the time in seconds. Thus I believe_getTTL
should return the time in secondsms / 1000
is there to convert from milliseconds to seconds (as expected byEX
)I didn't get what's wrong
You are right. That was a mistake by me. I just realized, I was setting "second" value in "maxAge" in express-session instead millisecond.
It's all working fine. Closing the issue.