You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: http_cache/varnish.rst
+6-5Lines changed: 6 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -70,10 +70,11 @@ into :ref:`caching pages that contain CSRF protected forms <caching-pages-that-c
70
70
Cookies created in JavaScript and used only in the frontend, e.g. when using
71
71
Google Analytics, are nonetheless sent to the server. These cookies are not
72
72
relevant for the backend and should not affect the caching decision. Configure
73
-
your Varnish cache to `clean the cookies header`_. You want to keep the
74
-
session cookie, if there is one, and get rid of all other cookies so that pages
75
-
are cached if there is no active session. Unless you changed the default
76
-
configuration of PHP, your session cookie has the name ``PHPSESSID``:
73
+
your Varnish cache to `clean the cookies header`_.
74
+
The goal is to retain only essential cookies—such as session cookies—and remove all others.
75
+
By doing this, pages can still be cached when there is no active session.
76
+
If you are using PHP and have not changed its default configuration, the session cookie is typically named PHPSESSID.
77
+
Additionally, if your application relies on other important cookies, such as a "REMEMBERME" cookie for "remember me" functionality or "trusted_device" for 2FA, these cookies should also be preserved.
77
78
78
79
.. configuration-block::
79
80
@@ -84,7 +85,7 @@ configuration of PHP, your session cookie has the name ``PHPSESSID``:
84
85
if (req.http.Cookie) {
85
86
set req.http.Cookie = ";" + req.http.Cookie;
86
87
set req.http.Cookie = regsuball(req.http.Cookie, "; +", ";");
87
-
set req.http.Cookie = regsuball(req.http.Cookie, ";(PHPSESSID)=", "; \1=");
88
+
set req.http.Cookie = regsuball(req.http.Cookie, ";(PHPSESSID|REMEMBERME)=", "; \1=");
88
89
set req.http.Cookie = regsuball(req.http.Cookie, ";[^ ][^;]*", "");
89
90
set req.http.Cookie = regsuball(req.http.Cookie, "^[; ]+|[; ]+$", "");
0 commit comments