1
0
mirror of https://github.com/astaxie/beego.git synced 2025-07-10 03:10:18 +00:00

session: support cookie domain

This commit is contained in:
astaxie
2014-08-04 16:21:06 +08:00
parent 474a16a7a0
commit d7a5281bda
3 changed files with 8 additions and 2 deletions

View File

@ -72,6 +72,7 @@ type managerConfig struct {
SessionIDHashKey string `json:"sessionIDHashKey"`
CookieLifeTime int `json:"cookieLifeTime"`
ProviderConfig string `json:"providerConfig"`
Domain string `json:"domain"`
}
// Manager contains Provider and its configuration.
@ -134,7 +135,8 @@ func (manager *Manager) SessionStart(w http.ResponseWriter, r *http.Request) (se
Value: url.QueryEscape(sid),
Path: "/",
HttpOnly: true,
Secure: manager.config.Secure}
Secure: manager.config.Secure,
Domain: manager.config.Domain}
if manager.config.CookieLifeTime >= 0 {
cookie.MaxAge = manager.config.CookieLifeTime
}
@ -153,7 +155,8 @@ func (manager *Manager) SessionStart(w http.ResponseWriter, r *http.Request) (se
Value: url.QueryEscape(sid),
Path: "/",
HttpOnly: true,
Secure: manager.config.Secure}
Secure: manager.config.Secure,
Domain: manager.config.Domain}
if manager.config.CookieLifeTime >= 0 {
cookie.MaxAge = manager.config.CookieLifeTime
}
@ -208,6 +211,7 @@ func (manager *Manager) SessionRegenerateId(w http.ResponseWriter, r *http.Reque
Path: "/",
HttpOnly: true,
Secure: manager.config.Secure,
Domain: manager.config.Domain,
}
} else {
oldsid, _ := url.QueryUnescape(cookie.Value)