]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
* Allow to unset cookies via negative lifetime values
authorRuediger Pluem <rpluem@apache.org>
Tue, 11 Feb 2025 10:29:03 +0000 (10:29 +0000)
committerRuediger Pluem <rpluem@apache.org>
Tue, 11 Feb 2025 10:29:03 +0000 (10:29 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1923725 13f79535-47bb-0310-9956-ffa450edef68

changes-entries/mod_rewrite_unset_cookie.txt [new file with mode: 0644]
docs/manual/rewrite/flags.xml
modules/mappers/mod_rewrite.c

diff --git a/changes-entries/mod_rewrite_unset_cookie.txt b/changes-entries/mod_rewrite_unset_cookie.txt
new file mode 100644 (file)
index 0000000..e2d70ca
--- /dev/null
@@ -0,0 +1 @@
+  *) mod_rewrite: Allow to unset cookies in the browser. [Ruediger Pluem]
index 278ede0e383c73af977aeb4976b6a74f0c89b8de..7ccd77a1efbc7b193b7bc787190df78423721a7c 100644 (file)
@@ -223,6 +223,7 @@ security model.</dd>
 <dd>A value of 0 indicates that the cookie will persist only for the
 current browser session. This is the default value if none is
 specified.</dd>
+<dd>A negative value causes the cookie to be unset in the browser.</dd>
 
 <dt>Path</dt>
 <dd>The path, on the current website, for which the cookie is valid,
index a720b1edb615832c202f5adaf283ec6f7fa3e11a..b565fb6974036cd848c4c5f3469792ac42d1d27d 100644 (file)
@@ -2758,7 +2758,7 @@ static void add_cookie(request_rec *r, char *s)
                 long exp_min;
 
                 exp_min = atol(expires);
-                if (exp_min) {
+                if (exp_min > 0) {
                     apr_time_exp_gmt(&tms, r->request_time
                                      + apr_time_from_sec((60 * exp_min)));
                     exp_time = apr_psprintf(r->pool, "%s, %.2d-%s-%.4d "
@@ -2769,6 +2769,9 @@ static void add_cookie(request_rec *r, char *s)
                                            tms.tm_year+1900,
                                            tms.tm_hour, tms.tm_min, tms.tm_sec);
                 }
+                else if (exp_min < 0) {
+                    exp_time = "Thu, 01 Jan 1970 00:00:00 GMT";
+                }
             }
 
             cookie = apr_pstrcat(rmain->pool,