28 lines
501 B
Go
28 lines
501 B
Go
package api
|
|
|
|
import (
|
|
"encoding/gob"
|
|
"github.com/gorilla/securecookie"
|
|
"github.com/gorilla/sessions"
|
|
. "main.go/type"
|
|
)
|
|
|
|
|
|
// sessions 存储于文件系统
|
|
var Store *sessions.FilesystemStore
|
|
|
|
func init() {
|
|
Store = sessions.NewFilesystemStore("./sessions", securecookie.GenerateRandomKey(32))
|
|
|
|
Store.Options = &sessions.Options{
|
|
Domain: "",
|
|
Path: "/",
|
|
MaxAge: 24 * 60 * 60, // 1 day
|
|
// SameSite: http.SameSiteNoneMode,
|
|
Secure: false,
|
|
HttpOnly: false,
|
|
}
|
|
|
|
gob.Register(User{})
|
|
}
|