use last cookie matching
This commit is contained in:
@@ -183,9 +183,14 @@ func requestLoginCookie(r *http.Request) (User, bool) {
|
||||
}
|
||||
|
||||
func getCookie(key string, r *http.Request) (string, bool) {
|
||||
cookie, err := r.Cookie(key)
|
||||
if err != nil {
|
||||
log.Printf("err getting cookie %s: %v: %+v", key, err, r.Cookies())
|
||||
var cookie *http.Cookie
|
||||
cookies := r.Cookies()
|
||||
for i := range cookies {
|
||||
if cookies[i].Name == key && (cookies[i].Expires.IsZero() || time.Now().Before(cookies[i].Expires)) {
|
||||
cookie = cookies[i]
|
||||
}
|
||||
}
|
||||
if cookie == nil {
|
||||
return "", false
|
||||
}
|
||||
return cookie.Value, cookie.Expires.IsZero() || time.Now().Before(cookie.Expires)
|
||||
|
||||
Reference in New Issue
Block a user