예제 #1
0
func registerSession() error {
	if BConfig.WebConfig.Session.SessionOn {
		var err error
		sessionConfig := AppConfig.String("sessionConfig")
		conf := new(session.ManagerConfig)
		if sessionConfig == "" {
			conf.CookieName = BConfig.WebConfig.Session.SessionName
			conf.EnableSetCookie = BConfig.WebConfig.Session.SessionAutoSetCookie
			conf.Gclifetime = BConfig.WebConfig.Session.SessionGCMaxLifetime
			conf.Secure = BConfig.Listen.EnableHTTPS
			conf.CookieLifeTime = BConfig.WebConfig.Session.SessionCookieLifeTime
			conf.ProviderConfig = filepath.ToSlash(BConfig.WebConfig.Session.SessionProviderConfig)
			conf.Domain = BConfig.WebConfig.Session.SessionDomain
			conf.EnableSidInHttpHeader = BConfig.WebConfig.Session.EnableSidInHttpHeader
			conf.SessionNameInHttpHeader = BConfig.WebConfig.Session.SessionNameInHttpHeader
			conf.EnableSidInUrlQuery = BConfig.WebConfig.Session.EnableSidInUrlQuery
		} else {
			if err = json.Unmarshal([]byte(sessionConfig), conf); err != nil {
				return err
			}
		}
		if GlobalSessions, err = session.NewManager(BConfig.WebConfig.Session.SessionProvider, conf); err != nil {
			return err
		}
		go GlobalSessions.GC()
	}
	return nil
}
예제 #2
0
///////////////////////////////////////////////////////
// init function
func init() {
	conf := new(session.ManagerConfig)
	conf.CookieName = "computerspielplatzID"
	conf.EnableSetCookie = true
	conf.Gclifetime = 3600
	conf.Secure = false
	conf.CookieLifeTime = 3600
	conf.ProviderConfig = ""

	globalSessions, _ = session.NewManager("memory", conf)
	go globalSessions.GC()

	SessionXsrfTable.Tokens = make(map[string]SessionXsrfStruct)
}
예제 #3
0
파일: session_init.go 프로젝트: shaalx/gooj
func init() {
	// GlobalSessions, _ = session.NewManager("memory", `{"cookieName":"gosessionid", "enableSetCookie,omitempty": true, "gclifetime":3600, "maxLifetime": 3600, "secure": false, "sessionIDHashFunc": "sha1", "sessionIDHashKey": "", "cookieLifeTime": 3600, "providerConfig": ""}`)
	// GlobalSessions, _ = session.NewManager("file", `{"cookieName":"gosessionid","sessionsavepath":"./sessionpath/", "enableSetCookie,omitempty": true, "gclifetime":3600, "maxLifetime": 3600, "secure": false, "sessionIDHashFunc": "sha1", "sessionIDHashKey": "", "cookieLifeTime": 3600, "providerConfig": ""}`)
	ssn := session.ManagerConfig{}
	ssn.CookieName = "gosessionid"
	ssn.EnableSetCookie = true
	ssn.Gclifetime = 3600
	ssn.EnableSetCookie = true
	ssn.Maxlifetime = 3600

	GlobalSessions, _ = session.NewManager("file", &ssn)
	// GlobalSessions, _ = session.NewManager("mysql", `{"cookieName":"gosessionid","sessionsavepath":"./sessionpath/", "enableSetCookie,omitempty": true, "gclifetime":3600, "maxLifetime": 3600, "secure": false, "sessionIDHashFunc": "sha1", "sessionIDHashKey": "", "cookieLifeTime": 3600, "providerConfig": "root:1234@tcp(localhost:3306)/session?charset=utf8"}`)
	// GlobalSessions, _ = session.NewManager("mysql", `{"cookieName":"gosessionid","sessionsavepath":"./sessionpath/", "enableSetCookie,omitempty": true, "gclifetime":3600, "maxLifetime": 3600, "secure": false, "sessionIDHashFunc": "sha1", "sessionIDHashKey": "", "cookieLifeTime": 3600, "providerConfig": "goojle:Goojle1234@tcp(121.42.161.248:3306)/gooj?charset=utf8"}`)
	// GlobalSessions, _ = session.NewManager("mysql", `{"cookieName":"gosessionid","gclifetime":3600,"ProviderConfig":"goojle:Goojle1234@tcp(121.42.161.248:3306)/gooj?charset=utf8"}`)
	// GlobalSessions, _ = session.NewManager("mysql", `{"cookieName":"gosessionid","sessionsavepath":"./sessionpath/", "enableSetCookie,omitempty": true, "gclifetime":3600, "maxLifetime": 3600, "secure": false, "sessionIDHashFunc": "sha1", "sessionIDHashKey": "", "cookieLifeTime": 3600, "providerConfig": "goojle:Goojle1234@tcp(121.42.161.248:3306)/gooj?charset=utf8"}`)
	defer GlobalSessions.GC()
}