You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cloudreve/middleware/session.go

16 lines
449 B

5 years ago
package middleware
import (
"github.com/gin-contrib/sessions"
"github.com/gin-contrib/sessions/memstore"
5 years ago
"github.com/gin-gonic/gin"
)
// Session 初始化session
func Session(secret string) gin.HandlerFunc {
store := memstore.NewStore([]byte(secret))
5 years ago
//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)
}