mirror of
https://github.com/astaxie/beego.git
synced 2024-11-26 04:01:29 +00:00
fix session cookies's expirded
This commit is contained in:
parent
3ad639e739
commit
a95d6f39f1
@ -61,9 +61,17 @@ func (manager *Manager) SessionStart(w http.ResponseWriter, r *http.Request) (se
|
|||||||
if err != nil || cookie.Value == "" {
|
if err != nil || cookie.Value == "" {
|
||||||
sid := manager.sessionId()
|
sid := manager.sessionId()
|
||||||
session, _ = manager.provider.SessionRead(sid)
|
session, _ = manager.provider.SessionRead(sid)
|
||||||
cookie := http.Cookie{Name: manager.cookieName, Value: url.QueryEscape(sid), Path: "/", HttpOnly: true, MaxAge: int(manager.maxlifetime)}
|
cookie := http.Cookie{Name: manager.cookieName,
|
||||||
|
Value: url.QueryEscape(sid),
|
||||||
|
Path: "/",
|
||||||
|
HttpOnly: true,
|
||||||
|
Secure: true}
|
||||||
|
cookie.Expires = time.Now().Add(time.Duration(manager.maxlifetime) * time.Second)
|
||||||
http.SetCookie(w, &cookie)
|
http.SetCookie(w, &cookie)
|
||||||
|
r.AddCookie(&cookie)
|
||||||
} else {
|
} else {
|
||||||
|
cookie.Expires = time.Now().Add(time.Duration(manager.maxlifetime) * time.Second)
|
||||||
|
http.SetCookie(w, cookie)
|
||||||
sid, _ := url.QueryUnescape(cookie.Value)
|
sid, _ := url.QueryUnescape(cookie.Value)
|
||||||
session, _ = manager.provider.SessionRead(sid)
|
session, _ = manager.provider.SessionRead(sid)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user