Skip to content

Commit 4957500

Browse files
committed
Add info for essential cookies (such as REMEMBERME)
1 parent bdd52e3 commit 4957500

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

http_cache/varnish.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,11 @@ into :ref:`caching pages that contain CSRF protected forms <caching-pages-that-c
7070
Cookies created in JavaScript and used only in the frontend, e.g. when using
7171
Google Analytics, are nonetheless sent to the server. These cookies are not
7272
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.
7778

7879
.. configuration-block::
7980

@@ -84,7 +85,7 @@ configuration of PHP, your session cookie has the name ``PHPSESSID``:
8485
if (req.http.Cookie) {
8586
set req.http.Cookie = ";" + req.http.Cookie;
8687
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=");
8889
set req.http.Cookie = regsuball(req.http.Cookie, ";[^ ][^;]*", "");
8990
set req.http.Cookie = regsuball(req.http.Cookie, "^[; ]+|[; ]+$", "");
9091

0 commit comments

Comments
 (0)