mirror of
https://github.com/keven1024/015.git
synced 2026-05-26 15:13:30 +00:00
17 lines
364 B
Go
17 lines
364 B
Go
package utils
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/gorilla/sessions"
|
|
"github.com/labstack/echo/v5"
|
|
)
|
|
|
|
func GetSession(c *echo.Context, name string) (*sessions.Session, error) {
|
|
store, err := echo.ContextGet[sessions.Store](c, "_session_store")
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to get session store: %w", err)
|
|
}
|
|
return store.Get(c.Request(), name)
|
|
}
|