Просмотр исходного кода

Set cookie attribute SameSite to strict mode

Frédéric Guillot 7 лет назад
Родитель
Сommit
88e81d4d80
1 измененных файлов с 2 добавлено и 0 удалено
  1. 2 0
      http/cookie/cookie.go

+ 2 - 0
http/cookie/cookie.go

@@ -27,6 +27,7 @@ func New(name, value string, isHTTPS bool, path string) *http.Cookie {
 		Secure:   isHTTPS,
 		HttpOnly: true,
 		Expires:  time.Now().Add(cookieDuration * 24 * time.Hour),
+		SameSite: http.SameSiteStrictMode,
 	}
 }
 
@@ -40,6 +41,7 @@ func Expired(name string, isHTTPS bool, path string) *http.Cookie {
 		HttpOnly: true,
 		MaxAge:   -1,
 		Expires:  time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC),
+		SameSite: http.SameSiteStrictMode,
 	}
 }