提交 9cbd4757 编写于 作者: A astaxie

beego support new version session

上级 481448fa
...@@ -191,14 +191,19 @@ func Run() { ...@@ -191,14 +191,19 @@ func Run() {
} }
if SessionOn { if SessionOn {
sessionConfig := AppConfig.String("sessionConfig")
if sessionConfig == "" {
sessionConfig = `{"cookieName":` + SessionName + `,` +
`"gclifetime":` + SessionGCMaxLifetime + `,` +
`"providerConfig":` + SessionSavePath + `,` +
`"secure":` + HttpTLS + `,` +
`"sessionIDHashFunc":` + SessionHashFunc + `,` +
`"sessionIDHashKey":` + SessionHashKey + `,` +
`"enableSetCookie":` + SessionAutoSetCookie + `,` +
`"cookieLifeTime":` + SessionCookieLifeTime + `,}`
}
GlobalSessions, _ = session.NewManager(SessionProvider, GlobalSessions, _ = session.NewManager(SessionProvider,
SessionName, sessionConfig)
SessionGCMaxLifetime,
SessionSavePath,
HttpTLS,
SessionHashFunc,
SessionHashKey,
SessionCookieLifeTime)
go GlobalSessions.GC() go GlobalSessions.GC()
} }
......
...@@ -40,6 +40,7 @@ var ( ...@@ -40,6 +40,7 @@ var (
SessionHashFunc string // session hash generation func. SessionHashFunc string // session hash generation func.
SessionHashKey string // session hash salt string. SessionHashKey string // session hash salt string.
SessionCookieLifeTime int // the life time of session id in cookie. SessionCookieLifeTime int // the life time of session id in cookie.
SessionAutoSetCookie bool // auto setcookie
UseFcgi bool UseFcgi bool
MaxMemory int64 MaxMemory int64
EnableGzip bool // flag of enable gzip EnableGzip bool // flag of enable gzip
...@@ -96,6 +97,7 @@ func init() { ...@@ -96,6 +97,7 @@ func init() {
SessionHashFunc = "sha1" SessionHashFunc = "sha1"
SessionHashKey = "beegoserversessionkey" SessionHashKey = "beegoserversessionkey"
SessionCookieLifeTime = 0 //set cookie default is the brower life SessionCookieLifeTime = 0 //set cookie default is the brower life
SessionAutoSetCookie = true
UseFcgi = false UseFcgi = false
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册