mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 18:10:54 +00:00
#254 add SessionHashFunc SessionHashKey SessionCookieLifeTime
This commit is contained in:
parent
9ccdb31003
commit
23d79b8b05
9
beego.go
9
beego.go
@ -71,7 +71,14 @@ func Run() {
|
||||
}
|
||||
|
||||
if SessionOn {
|
||||
GlobalSessions, _ = session.NewManager(SessionProvider, SessionName, SessionGCMaxLifetime, SessionSavePath, HttpTLS)
|
||||
GlobalSessions, _ = session.NewManager(SessionProvider,
|
||||
SessionName,
|
||||
SessionGCMaxLifetime,
|
||||
SessionSavePath,
|
||||
HttpTLS,
|
||||
SessionHashFunc,
|
||||
SessionHashKey,
|
||||
SessionCookieLifeTime)
|
||||
go GlobalSessions.GC()
|
||||
}
|
||||
|
||||
|
24
config.go
24
config.go
@ -36,6 +36,9 @@ var (
|
||||
SessionName string // sessionName cookie's name
|
||||
SessionGCMaxLifetime int64 // session's gc maxlifetime
|
||||
SessionSavePath string // session savepath if use mysql/redis/file this set to the connectinfo
|
||||
SessionHashFunc string
|
||||
SessionHashKey string
|
||||
SessionCookieLifeTime int
|
||||
UseFcgi bool
|
||||
MaxMemory int64
|
||||
EnableGzip bool // enable gzip
|
||||
@ -71,6 +74,9 @@ func init() {
|
||||
SessionName = "beegosessionID"
|
||||
SessionGCMaxLifetime = 3600
|
||||
SessionSavePath = ""
|
||||
SessionHashFunc = "sha1"
|
||||
SessionHashKey = "beegoserversessionkey"
|
||||
SessionCookieLifeTime = 3600
|
||||
UseFcgi = false
|
||||
MaxMemory = 1 << 26 //64MB
|
||||
EnableGzip = false
|
||||
@ -157,6 +163,18 @@ func ParseConfig() (err error) {
|
||||
if sesssavepath := AppConfig.String("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 {
|
||||
int64val, _ := strconv.ParseInt(strconv.Itoa(sessMaxLifeTime), 10, 64)
|
||||
SessionGCMaxLifetime = int64val
|
||||
@ -165,6 +183,12 @@ func ParseConfig() (err error) {
|
||||
int64val, _ := strconv.ParseInt(strconv.Itoa(sessMaxLifeTime), 10, 64)
|
||||
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 {
|
||||
UseFcgi = usefcgi
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user