Commit 23d79b8b authored by astaxie's avatar astaxie

#254 add SessionHashFunc SessionHashKey SessionCookieLifeTime

parent 9ccdb310
...@@ -71,7 +71,14 @@ func Run() { ...@@ -71,7 +71,14 @@ func Run() {
} }
if SessionOn { if SessionOn {
GlobalSessions, _ = session.NewManager(SessionProvider, SessionName, SessionGCMaxLifetime, SessionSavePath, HttpTLS) GlobalSessions, _ = session.NewManager(SessionProvider,
SessionName,
SessionGCMaxLifetime,
SessionSavePath,
HttpTLS,
SessionHashFunc,
SessionHashKey,
SessionCookieLifeTime)
go GlobalSessions.GC() go GlobalSessions.GC()
} }
......
...@@ -36,6 +36,9 @@ var ( ...@@ -36,6 +36,9 @@ var (
SessionName string // sessionName cookie's name SessionName string // sessionName cookie's name
SessionGCMaxLifetime int64 // session's gc maxlifetime SessionGCMaxLifetime int64 // session's gc maxlifetime
SessionSavePath string // session savepath if use mysql/redis/file this set to the connectinfo SessionSavePath string // session savepath if use mysql/redis/file this set to the connectinfo
SessionHashFunc string
SessionHashKey string
SessionCookieLifeTime int
UseFcgi bool UseFcgi bool
MaxMemory int64 MaxMemory int64
EnableGzip bool // enable gzip EnableGzip bool // enable gzip
...@@ -71,6 +74,9 @@ func init() { ...@@ -71,6 +74,9 @@ func init() {
SessionName = "beegosessionID" SessionName = "beegosessionID"
SessionGCMaxLifetime = 3600 SessionGCMaxLifetime = 3600
SessionSavePath = "" SessionSavePath = ""
SessionHashFunc = "sha1"
SessionHashKey = "beegoserversessionkey"
SessionCookieLifeTime = 3600
UseFcgi = false UseFcgi = false
MaxMemory = 1 << 26 //64MB MaxMemory = 1 << 26 //64MB
EnableGzip = false EnableGzip = false
...@@ -157,6 +163,18 @@ func ParseConfig() (err error) { ...@@ -157,6 +163,18 @@ func ParseConfig() (err error) {
if sesssavepath := AppConfig.String("SessionSavePath"); sesssavepath != "" { if sesssavepath := AppConfig.String("SessionSavePath"); sesssavepath != "" {
SessionSavePath = sesssavepath SessionSavePath = sesssavepath
} }
if sesshashfunc := AppConfig.String("sessionhashfunc"); sesshashfunc != "" {
SessionHashFunc = sesshashfunc
}
if sesshashfunc := AppConfig.String("SessionHashFunc"); sesshashfunc != "" {
SessionHashFunc = sesshashfunc
}
if sesshashkey := AppConfig.String("sessionhashkey"); sesshashkey != "" {
SessionHashKey = sesshashkey
}
if sesshashkey := AppConfig.String("SessionHashKey"); sesshashkey != "" {
SessionHashKey = sesshashkey
}
if sessMaxLifeTime, err := AppConfig.Int("sessiongcmaxlifetime"); err == nil && sessMaxLifeTime != 0 { if sessMaxLifeTime, err := AppConfig.Int("sessiongcmaxlifetime"); err == nil && sessMaxLifeTime != 0 {
int64val, _ := strconv.ParseInt(strconv.Itoa(sessMaxLifeTime), 10, 64) int64val, _ := strconv.ParseInt(strconv.Itoa(sessMaxLifeTime), 10, 64)
SessionGCMaxLifetime = int64val SessionGCMaxLifetime = int64val
...@@ -165,6 +183,12 @@ func ParseConfig() (err error) { ...@@ -165,6 +183,12 @@ func ParseConfig() (err error) {
int64val, _ := strconv.ParseInt(strconv.Itoa(sessMaxLifeTime), 10, 64) int64val, _ := strconv.ParseInt(strconv.Itoa(sessMaxLifeTime), 10, 64)
SessionGCMaxLifetime = int64val SessionGCMaxLifetime = int64val
} }
if sesscookielifetime, err := AppConfig.Int("sessioncookielifelime"); err == nil && sesscookielifetime != 0 {
SessionCookieLifeTime = sesscookielifetime
}
if sesscookielifetime, err := AppConfig.Int("SessionCookieLifeTime"); err == nil && sesscookielifetime != 0 {
SessionCookieLifeTime = sesscookielifetime
}
if usefcgi, err := AppConfig.Bool("usefcgi"); err == nil { if usefcgi, err := AppConfig.Bool("usefcgi"); err == nil {
UseFcgi = usefcgi UseFcgi = usefcgi
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment