From bfe48924c7c76e748964fcad4330c277ccf05ee5 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Thu, 4 Jan 2024 23:10:08 +0000 Subject: [PATCH] Improve cookie parameters --- app/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index e4360853..b184c5b9 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -191,7 +191,7 @@ def set_locale(): if locale: expire_date = datetime.datetime.now() expire_date = expire_date + datetime.timedelta(days=5*365) - resp.set_cookie("locale", locale, expires=expire_date) + resp.set_cookie("locale", locale, expires=expire_date, secure=True, samesite="Lax") if current_user.is_authenticated: current_user.locale = locale @@ -204,10 +204,10 @@ def set_locale(): def set_nonfree(): resp = redirect(url_for("homepage.home")) if request.cookies.get("hide_nonfree") == "1": - resp.set_cookie("hide_nonfree", "0", expires=0) + resp.set_cookie("hide_nonfree", "0", expires=0, secure=True, samesite="Lax") else: expire_date = datetime.datetime.now() expire_date = expire_date + datetime.timedelta(days=5*365) - resp.set_cookie("hide_nonfree", "1", expires=expire_date) + resp.set_cookie("hide_nonfree", "1", expires=expire_date, secure=True, samesite="Lax") return resp