You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey there I found an issue with the memorysession. When a route has a path parameter sessions is not immediately updated after the route is processed. Using the memorysession example in the repo add the route login/{id} as shown below
Update the login handler to actually use the path parameter like so
# view.nimimport prologue
prochello*(ctx: Context) {.async.} =resp"<h1>Hello, Prologue!</h1>"proclogin*(ctx: Context) {.async.} =
ctx.session["flywind"] ="123"
ctx.session["ordontfly"] ="345"## Be careful when using session or csrf middlewares,## Response object will cover the headers of before.resphtmlResponse("<h1>Login</h1>"&$ctx.getPathParams("id"), headers = ctx.response.headers)
procprint*(ctx: Context) {.async.} =resp$ctx.session
proclogout*(ctx: Context) {.async.} =
ctx.session.clear()
resphtmlResponse("<h1>Logout</h1>", headers = ctx.response.headers)
Now when you run the app and now call http://localhost:8080/login/1 and then check http://localhost:8080/print as before you will see session is empty.
Route http://localhost:8080/login works just fine as before
The text was updated successfully, but these errors were encountered:
Hey there I found an issue with the memorysession. When a route has a path parameter sessions is not immediately updated after the route is processed. Using the memorysession example in the repo add the route
login/{id}
as shown belowUpdate the
login
handler to actually use the path parameter like soNow when you run the app and now call
http://localhost:8080/login/1
and then checkhttp://localhost:8080/print
as before you will see session is empty.Route
http://localhost:8080/login
works just fine as beforeThe text was updated successfully, but these errors were encountered: