Bug 28391 - CO (cookie) flag does not support session-based expiration with path specified
Summary: CO (cookie) flag does not support session-based expiration with path specified
Status: RESOLVED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_rewrite (show other bugs)
Version: 2.4.4
Hardware: All All
: P3 normal with 3 votes (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2004-04-14 20:02 UTC by Byron Guernsey
Modified: 2015-01-16 20:29 UTC (History)
1 user (show)



Attachments
patch file generated with diff -u mod_rewrite.c.orig mod_rewrite.c (902 bytes, patch)
2004-04-14 20:03 UTC, Byron Guernsey
Details | Diff
A new simpler patch I've been using (1.14 KB, patch)
2004-08-30 17:57 UTC, Byron Guernsey
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Byron Guernsey 2004-04-14 20:02:35 UTC
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
Comment 1 Byron Guernsey 2004-04-14 20:03:53 UTC
Created attachment 11239 [details]
patch file generated with diff -u mod_rewrite.c.orig mod_rewrite.c
Comment 2 Byron Guernsey 2004-08-30 17:57:23 UTC
Created attachment 12570 [details]
A new simpler patch I've been using
Comment 3 Eric Covener 2015-01-16 20:29:06 UTC
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