sessions icon indicating copy to clipboard operation
sessions copied to clipboard

Remove the dependency of `github.com/gorilla/context`

Open xuwei0455 opened this issue 4 years ago • 4 comments

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/sessionshad removed the dependency, so why we need to keep the dependency?

xuwei0455 avatar Jul 23 '19 02:07 xuwei0455

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.

maximerety avatar Jun 23 '20 14:06 maximerety

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.

GwynethLlewelyn avatar Jun 28 '20 23:06 GwynethLlewelyn

@maximerety FYI: https://github.com/gin-contrib/sessions/pull/151

KeiichiHirobe avatar Mar 19 '22 04:03 KeiichiHirobe

Got the same issue. Why 151 didn't get merged?

marvin-min avatar Jun 20 '23 14:06 marvin-min