Files
PMail/server/session/init.go
2023-07-30 17:59:25 +08:00

20 lines
446 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package session
import (
"github.com/alexedwards/scs/mysqlstore"
"github.com/alexedwards/scs/v2"
"pmail/mysql"
"time"
)
var Instance *scs.SessionManager
func Init() {
Instance = scs.New()
Instance.Lifetime = 24 * time.Hour
// 使用mysql存储session数据目前为了架构简单
// 暂不引入redis存储如果日后性能存在瓶颈可以将session迁移到redis
Instance.Store = mysqlstore.New(mysql.Instance.DB)
}