The cookie flag with mod_rewrite does not allow you to expire a cookie when the browser closes if you also need to specify a path. For example: RewriteRule (.*) - [CO=MyCookie:value::/somepath] Actually results in /somepath being copied into the variable expires in mod_rewrite.c:addcookie() and path being set to NULL. This results in expires being set to 0, a cookie being generated for the current time/date, and the path being set to NULL, which seems like a bug. likewise, the following line will result in a cookie being set that expires immediately: RewriteRule (.*) - [CO=MyCookie:value:0:/somepath] I've written a patch that allows 0 or "::" to indicate that the cookie is valid for the current session. The only time I can imagine that a user would want to set a cookie to "now+0" is if he is trying to expire an existing cookie, and in that case "now+(-1)" will work much better, and I believe this is supported by specifying -1 in the CO flag field for the expire time. Basically, I needed to set a cookie that is for a particular path and is good only while the browser is open. So my patch checks for the improper tokenization of the path into the expires field and moves the path into the proper variable and reassigns expires to NULL. If determines this by testing to see if expires != NULL, atol(expires)==0, path==NULL and !apr_isdigit(*expires). The only case this logic could fail is if the path is specified as a number as the first digit, but a cookie path must begin with a / to be well formed. See the patch which I will attach. This is against 2.0.49. I hope that this can be included in a future revision, or the concept of the patch can be accomplished. Thanks, Byron Guernsey GE Consumer & Industrial Products
Created attachment 11239 [details] patch file generated with diff -u mod_rewrite.c.orig mod_rewrite.c
Created attachment 12570 [details] A new simpler patch I've been using
Sorry this did not get any attention. In a separate bug it was noticed that this feature made it into the 2.2 docs. The feature was subsequently added for 2.2.29 and is of course present in later releases already. PR56014