Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMHSanaei <ho3ein.sanaei@gmail.com>2026-04-20 15:00:18 +0300
committerMHSanaei <ho3ein.sanaei@gmail.com>2026-04-20 15:00:18 +0300
commitc188056f64be268dda8f7c16e23f7ef9c90d014f (patch)
tree4494f90a3447f92dbfc6751a5ddcbf34a7f9d26c /web/session/session.go
parent0a424a9f160b0193bd8064b94e54aa1bfb9f0de5 (diff)
Centralize session options and adjust cookies
Configure session cookie options centrally in initRouter and remove per-login MaxAge handling. Deleted SetMaxAge helper and its use in the login flow; session.Options are now applied once using basePath with HttpOnly and SameSite defaults, and MaxAge is set only when the stored setting is available and >0. Also make CookieManager.setCookie treat exdays as optional (only add expires when provided) and stop using a hardcoded 150-day expiry for the lang cookie in the JS language manager. Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
Diffstat (limited to 'web/session/session.go')
-rw-r--r--web/session/session.go12
1 files changed, 0 insertions, 12 deletions
diff --git a/web/session/session.go b/web/session/session.go
index 63da426b..95b85227 100644
--- a/web/session/session.go
+++ b/web/session/session.go
@@ -31,18 +31,6 @@ func SetLoginUser(c *gin.Context, user *model.User) {
s.Set(loginUserKey, *user)
}
-// SetMaxAge configures the session cookie maximum age in seconds.
-// This controls how long the session remains valid before requiring re-authentication.
-func SetMaxAge(c *gin.Context, maxAge int) {
- s := sessions.Default(c)
- s.Options(sessions.Options{
- Path: defaultPath,
- MaxAge: maxAge,
- HttpOnly: true,
- SameSite: http.SameSiteLaxMode,
- })
-}
-
// GetLoginUser retrieves the authenticated user from the session.
// Returns nil if no user is logged in or if the session data is invalid.
func GetLoginUser(c *gin.Context) *model.User {