Skip to content

Commit

Permalink
Improve cookie parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenwardy committed Jan 4, 2024
1 parent 7ce2ee1 commit bfe4892
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit bfe4892

Please sign in to comment.