diff --git a/session/session.go b/session/session.go index 4a0a726..f041bc8 100644 --- a/session/session.go +++ b/session/session.go @@ -1,6 +1,8 @@ package session import ( + "fmt" + "github.com/gorilla/context" "github.com/gorilla/sessions" "github.com/labstack/echo/v4" @@ -32,7 +34,11 @@ var ( // Get returns a named session. func Get(name string, c echo.Context) (*sessions.Session, error) { - store := c.Get(key).(sessions.Store) + s := c.Get(key) + if s == nil { + return nil, fmt.Errorf("%q session not found", name) + } + store := s.(sessions.Store) return store.Get(c.Request(), name) }