gorilla / sessions

Package gorilla/sessions provides cookie and filesystem sessions and infrastructure for custom session backends.
https://gorilla.github.io
BSD 3-Clause "New" or "Revised" License
2.93k stars 371 forks source link

redigo: get on closed pool #258

Closed xujb977644703 closed 6 months ago

xujb977644703 commented 2 years ago

// Add a value session.Values["foo"] = "bar"

// Save session
if err = sessions.Save(req, w); err != nil {
    log.Fatal("failed saving session: ", err)
}

when the "bar" is interface{},the session.save is err,why?

elithrar commented 2 years ago

Don’t ignore the error here:

store, _ = redistore.NewRediStore(c.Redis.Db, "tcp", c.Redis.Addr, "", []byte("secret-keyS"))

amustaque97 commented 2 years ago

@xujb977644703 what is the error message?

bharat-rajani commented 7 months ago

@xujb977644703 I am not getting the error when using interface. Can you provide some code with which we can reproduce the error you would be facing?

func MyHandler(w http.ResponseWriter, r *http.Request) {
    session, _ := store.Get(r, "session-name")
    var a interface{}
    session.Values["foo"] = a
    session.Values[42] = 43
    err := session.Save(r, w)
    if err != nil {
        log.Default().Println(err)
        http.Error(w, err.Error(), http.StatusInternalServerError)
        return
    }
}
jaitaiwan commented 6 months ago

This issue appears to be specific to redis; I'm going to close this out unless we can come up with a test or example which proves a bug. Thanks!