mirror of
https://github.com/kataras/iris.git
synced 2025-12-20 03:17:04 +00:00
fix cookie expire equals to -1 when call UpdateExpiration
Former-commit-id: 69107db0f9be87db2057c6d261bd896c0358bc45
This commit is contained in:
@@ -31,9 +31,11 @@ func GetCookie(ctx context.Context, name string) string {
|
||||
}
|
||||
|
||||
// AddCookie adds a cookie
|
||||
func AddCookie(ctx context.Context, cookie *http.Cookie) {
|
||||
func AddCookie(ctx context.Context, cookie *http.Cookie, reclaim bool) {
|
||||
// http.SetCookie(ctx.ResponseWriter(), cookie)
|
||||
// ctx.Request().AddCookie(cookie)
|
||||
if reclaim {
|
||||
ctx.Request().AddCookie(cookie)
|
||||
}
|
||||
ctx.SetCookie(cookie)
|
||||
}
|
||||
|
||||
@@ -50,12 +52,7 @@ func RemoveCookie(ctx context.Context, name string, purge bool) {
|
||||
c.MaxAge = -1
|
||||
c.Value = ""
|
||||
c.Path = "/"
|
||||
AddCookie(ctx, c)
|
||||
|
||||
if purge {
|
||||
// delete request's cookie also, which is temporary available.
|
||||
ctx.Request().Header.Set("Cookie", "")
|
||||
}
|
||||
AddCookie(ctx, c, purge)
|
||||
}
|
||||
|
||||
// IsValidCookieDomain returns true if the receiver is a valid domain to set
|
||||
|
||||
Reference in New Issue
Block a user