[fix] Session Data Not Persisting in POST Requests in Koa Application
4i8 opened this issue · comments
Arth commented
Describe the bug
Node.js version:
v20.2.0
OS version:
win11
Description:
I am encountering an issue in my Koa application where setting ctx.session
works as expected in a GET request handler but does not work in a POST request handler. I expected the same behavior for both GET and POST requests.
Actual behavior
In the POST request handler, when I attempt to set ctx.session.token = "guest-2"
, the session data does not get updated, and subsequent requests do not reflect the change. However, the same code works as expected in a GET request handler.
Expected behavior
I expect to be able to set ctx.session.token
in both GET and POST request handlers, and the session data should be updated accordingly.
Code to reproduce
...get(..., async (ctx) => {
ctx.session.token = "guest"; //work
});
...post(..., async (ctx) => {
ctx.session.token = "guest-2";//not work
});
Checklist
- [ ✅] I have searched through GitHub issues for similar issues.
- [ ✅ ] I have completely read through the README and documentation.
- [ ✅ ] I have tested my code with the latest version of Node.js and this package and confirmed it is still not working.