123456789101112131415161718192021222324252627 |
- // Copyright 2019 githup.com. All rights reserved.
- // Use of this source code is governed by githup.com.
- package middleware
- import (
- "github.com/gin-contrib/sessions"
- "github.com/gin-contrib/sessions/cookie"
- "github.com/gin-gonic/gin"
- )
- func SessionConfig() sessions.Store {
- sessionMaxAge := 3600
- sessionSecret := "smart"
- var store sessions.Store
- store = cookie.NewStore([]byte(sessionSecret))
- store.Options(sessions.Options{
- MaxAge: sessionMaxAge, //seconds
- Path: "/",
- })
- return store
- }
- func Session(keyPairs string) gin.HandlerFunc {
- store := SessionConfig()
- return sessions.Sessions(keyPairs, store)
- }
|