summaryrefslogtreecommitdiffstats
path: root/modules/setting/session.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-02-10 09:37:37 +0800
committerGitHub <noreply@github.com>2019-02-10 09:37:37 +0800
commit820e28c9044bbd9d398dd1617323665bb0935e13 (patch)
tree67f57519600b6f7a11c695af7d72728636590456 /modules/setting/session.go
parent9e8cc3b18da7438b315676686d6552926cc2965a (diff)
downloadgitea-820e28c9044bbd9d398dd1617323665bb0935e13.tar.gz
gitea-820e28c9044bbd9d398dd1617323665bb0935e13.zip
Split setting.go as multiple files (#6014)
* split setting.go as multiple files * fix comments
Diffstat (limited to 'modules/setting/session.go')
-rw-r--r--modules/setting/session.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/modules/setting/session.go b/modules/setting/session.go
new file mode 100644
index 0000000000..97ac50d861
--- /dev/null
+++ b/modules/setting/session.go
@@ -0,0 +1,35 @@
+// Copyright 2019 The Gitea Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package setting
+
+import (
+ "path"
+ "path/filepath"
+ "strings"
+
+ "code.gitea.io/gitea/modules/log"
+ "github.com/go-macaron/session"
+)
+
+var (
+ // SessionConfig difines Session settings
+ SessionConfig session.Options
+)
+
+func newSessionService() {
+ SessionConfig.Provider = Cfg.Section("session").Key("PROVIDER").In("memory",
+ []string{"memory", "file", "redis", "mysql", "postgres", "couchbase", "memcache", "nodb"})
+ SessionConfig.ProviderConfig = strings.Trim(Cfg.Section("session").Key("PROVIDER_CONFIG").MustString(path.Join(AppDataPath, "sessions")), "\" ")
+ if SessionConfig.Provider == "file" && !filepath.IsAbs(SessionConfig.ProviderConfig) {
+ SessionConfig.ProviderConfig = path.Join(AppWorkPath, SessionConfig.ProviderConfig)
+ }
+ SessionConfig.CookieName = Cfg.Section("session").Key("COOKIE_NAME").MustString("i_like_gitea")
+ SessionConfig.CookiePath = AppSubURL
+ SessionConfig.Secure = Cfg.Section("session").Key("COOKIE_SECURE").MustBool(false)
+ SessionConfig.Gclifetime = Cfg.Section("session").Key("GC_INTERVAL_TIME").MustInt64(86400)
+ SessionConfig.Maxlifetime = Cfg.Section("session").Key("SESSION_LIFE_TIME").MustInt64(86400)
+
+ log.Info("Session Service Enabled")
+}