Cloudreve/middleware/session.go

19 lines
498 B
Go
Raw Normal View History

2019-11-11 06:13:17 -05:00
package middleware
import (
"github.com/gin-contrib/sessions"
"github.com/gin-contrib/sessions/memstore"
2019-11-11 06:13:17 -05:00
"github.com/gin-gonic/gin"
)
2019-11-12 02:34:54 -05:00
// Store session存储
var Store memstore.Store
2019-11-11 06:13:17 -05:00
// Session 初始化session
func Session(secret string) gin.HandlerFunc {
2019-11-12 02:34:54 -05:00
Store = memstore.NewStore([]byte(secret))
// Also set Secure: true if using SSL, you should though
Store.Options(sessions.Options{HttpOnly: true, MaxAge: 7 * 86400, Path: "/"})
return sessions.Sessions("cloudreve-session", Store)
2019-11-11 06:13:17 -05:00
}