// Copyright 2019 github.com. All rights reserved. // Use of this source code is governed by github.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) }