sessions
sessions copied to clipboard
Remove the dependency of `github.com/gorilla/context`
I found github.com/gorilla/context
had been in maintenance mode, After some search of dependency for it.
I truly just find one place that uses the gorilla context, as follows: https://github.com/gin-contrib/sessions/blob/master/sessions.go#L64
func Sessions(name string, store Store) gin.HandlerFunc {
return func(c *gin.Context) {
s := &session{name, c.Request, store, nil, false, c.Writer}
c.Set(DefaultKey, s)
defer context.Clear(c.Request)
c.Next()
}
}
even github.com/gorilla/sessions
had removed the dependency, so why we need to keep the dependency?
There are two occurrences now, with the addition of SessionsMany
.
This was an emulation of context
from a time when it wasn't a part of the standard library yet (golang < 1.7).
But what's bothering me the most is that the session is actually stored in a gin.Context
(c.Set(DefaultKey, s)
), which is definitely not the context that is cleared by defer context.Clear(c.Request)
.
Either I'm missing something or this does not make sense.
Ah! That certainly explains why I cannot clear a session, no matter how hard I try. It does not make any sense to me, either... see also #89 — I believe it might be related to this.
@maximerety FYI: https://github.com/gin-contrib/sessions/pull/151
Got the same issue. Why 151 didn't get merged?