9cbd4757 by astaxie

beego support new version session

1 parent 481448fa
...@@ -191,14 +191,19 @@ func Run() { ...@@ -191,14 +191,19 @@ func Run() {
191 } 191 }
192 192
193 if SessionOn { 193 if SessionOn {
194 sessionConfig := AppConfig.String("sessionConfig")
195 if sessionConfig == "" {
196 sessionConfig = `{"cookieName":` + SessionName + `,` +
197 `"gclifetime":` + SessionGCMaxLifetime + `,` +
198 `"providerConfig":` + SessionSavePath + `,` +
199 `"secure":` + HttpTLS + `,` +
200 `"sessionIDHashFunc":` + SessionHashFunc + `,` +
201 `"sessionIDHashKey":` + SessionHashKey + `,` +
202 `"enableSetCookie":` + SessionAutoSetCookie + `,` +
203 `"cookieLifeTime":` + SessionCookieLifeTime + `,}`
204 }
194 GlobalSessions, _ = session.NewManager(SessionProvider, 205 GlobalSessions, _ = session.NewManager(SessionProvider,
195 SessionName, 206 sessionConfig)
196 SessionGCMaxLifetime,
197 SessionSavePath,
198 HttpTLS,
199 SessionHashFunc,
200 SessionHashKey,
201 SessionCookieLifeTime)
202 go GlobalSessions.GC() 207 go GlobalSessions.GC()
203 } 208 }
204 209
......
...@@ -40,6 +40,7 @@ var ( ...@@ -40,6 +40,7 @@ var (
40 SessionHashFunc string // session hash generation func. 40 SessionHashFunc string // session hash generation func.
41 SessionHashKey string // session hash salt string. 41 SessionHashKey string // session hash salt string.
42 SessionCookieLifeTime int // the life time of session id in cookie. 42 SessionCookieLifeTime int // the life time of session id in cookie.
43 SessionAutoSetCookie bool // auto setcookie
43 UseFcgi bool 44 UseFcgi bool
44 MaxMemory int64 45 MaxMemory int64
45 EnableGzip bool // flag of enable gzip 46 EnableGzip bool // flag of enable gzip
...@@ -96,6 +97,7 @@ func init() { ...@@ -96,6 +97,7 @@ func init() {
96 SessionHashFunc = "sha1" 97 SessionHashFunc = "sha1"
97 SessionHashKey = "beegoserversessionkey" 98 SessionHashKey = "beegoserversessionkey"
98 SessionCookieLifeTime = 0 //set cookie default is the brower life 99 SessionCookieLifeTime = 0 //set cookie default is the brower life
100 SessionAutoSetCookie = true
99 101
100 UseFcgi = false 102 UseFcgi = false
101 103
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!