iris
iris copied to clipboard
[BUG] If two requests set up the Session at the same time, two will appear
I set up session A, and B
But I see two records in redis One contains A, the other contains B
After refreshing the browser, one contains A and the other contains A and B
Maybe the interval between two requests is too short?
Hello @kcrazy ,
I set up session A, and B. But I see two records in redis. One contains A, the other contains B.
I don't understand the issue, if you setup requests from two different browser tabs without a session cookie (= first time) at the same exact time then the server will see that none of those requests have a session cookie among with them, and it will create new ones and push a new cookie for each of the client requests to its responses, so the client can hold them (e.g. browser). This is normal.
After refreshing the browser, one contains A and the other contains A and B
Are you sure? You should be able to see both A and B cookies in the new requests (aka refresh) (if they are set at the exact same time and through the same exact domain or subdomain). Can you please provide an example?
Thanks, Gerasimos Maropoulos
Hello @kataras
This problem only appears in the v12.2.0-alpha2 version The v12.1.8 version seems to be normal
On the front end: Send 2 GET requests at same time
GET /request_a
GET /request_b
Iris Code:
func requestA(ctx iris.Context) {
mySessions.Start(ctx).Set("A", 1)
}
func requestB(ctx iris.Context) {
mySessions.Start(ctx).Set("B", 1)
}
func init() {
app.Get("/request_a", requestA)
app.Get("/request_b", requestB)
}
mySessions use redis database
You can see that there are two keys in redis, one contains A and one contains B.
I think the normal situation, should include both A and B in the same key
Thanks, kcrazy
The correct behavior is the current one, and had been always like that. The redis driver changed since v12.1.8, we are using HSET instead of Set after 12.1.8 (see here).
Yes, of course A and B keys should be included in the same entry. However I can't reproduce the issue. Can you try to set AllowReclaim
to true
on your sessions.Config
and try again?
in my sessions.Config AllowReclaim: true
, but there are still problems.
This means that the A value I set will be lost