The documentation regarding the use of options.key and the generation of the cookie name could be more clear and it would be nice if it used the same kind of fallback to options.cookie.name as options.ttl does.
I had the following scenario and assumed that this would work:
After some debugging I found out that if you only supply the cookie.name without the key property it will fail and recreate a session for every request. The cookie name is being picked up by the cookie.name property but the retrieval and storage of the session relies on the key property which defaults to 'koa.sid'.
I read the part about the ttl property being based on the cookie max age if you do not supply the ttl property. I would suggest doing the same for the key. If key is not supplied and cookie.name is set, fall back to that, otherwise fall back to the default 'koa.sid'.
I'm willing to do a PR to change this and update the read me accordingly.
The documentation regarding the use of
options.key
and the generation of the cookie name could be more clear and it would be nice if it used the same kind of fallback tooptions.cookie.name
asoptions.ttl
does.I had the following scenario and assumed that this would work:
After some debugging I found out that if you only supply the
cookie.name
without thekey
property it will fail and recreate a session for every request. The cookie name is being picked up by thecookie.name
property but the retrieval and storage of the session relies on thekey
property which defaults to 'koa.sid'.I read the part about the
ttl
property being based on the cookie max age if you do not supply thettl
property. I would suggest doing the same for the key. Ifkey
is not supplied andcookie.name
is set, fall back to that, otherwise fall back to the default 'koa.sid'.I'm willing to do a PR to change this and update the read me accordingly.