From: Ruediger Pluem Date: Sat, 7 Jun 2008 12:50:04 +0000 (+0000) Subject: * Offer the possibility to create session cookies in the case a path is X-Git-Tag: 2.3.0~514 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cf66e3894d30bf7608f703cde0a5af63d4485f78;p=thirdparty%2Fapache%2Fhttpd.git * Offer the possibility to create session cookies in the case a path is given. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@664333 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/docs/manual/mod/mod_rewrite.xml b/docs/manual/mod/mod_rewrite.xml index 2a66f4d3319..baa6038dca6 100644 --- a/docs/manual/mod/mod_rewrite.xml +++ b/docs/manual/mod/mod_rewrite.xml @@ -1257,7 +1257,8 @@ cannot use $N in the substitution string! is specified by NAME and the value is VAL. The domain field is the domain of the cookie, such as '.apache.org', the optional lifetime - is the lifetime of the cookie in minutes, and the optional + is the lifetime of the cookie in minutes (0 means expires at end + of session), and the optional path is the path of the cookie. If secure is set to 'secure', 'true' or '1', the cookie is only transmitted via secured connections. If httponly is set to 'HttpOnly', 'true' or '1', the diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c index 10e50dd9bf9..73379caeb0d 100644 --- a/modules/mappers/mod_rewrite.c +++ b/modules/mappers/mod_rewrite.c @@ -2475,23 +2475,30 @@ static void add_cookie(request_rec *r, char *s) if (expires) { apr_time_exp_t tms; - apr_time_exp_gmt(&tms, r->request_time - + apr_time_from_sec((60 * atol(expires)))); - exp_time = apr_psprintf(r->pool, "%s, %.2d-%s-%.4d " - "%.2d:%.2d:%.2d GMT", - apr_day_snames[tms.tm_wday], - tms.tm_mday, - apr_month_snames[tms.tm_mon], - tms.tm_year+1900, - tms.tm_hour, tms.tm_min, tms.tm_sec); + long exp_min; + + exp_min = atol(expires); + if (exp_min) { + 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 " + "%.2d:%.2d:%.2d GMT", + apr_day_snames[tms.tm_wday], + tms.tm_mday, + apr_month_snames[tms.tm_mon], + tms.tm_year+1900, + tms.tm_hour, tms.tm_min, tms.tm_sec); + } } cookie = apr_pstrcat(rmain->pool, var, "=", val, "; path=", path ? path : "/", "; domain=", domain, - expires ? "; expires=" : NULL, - expires ? exp_time : NULL, + expires ? (exp_time ? "; expires=" : "") + : NULL, + expires ? (exp_time ? exp_time : "") + : NULL, (secure && (!strcasecmp(secure, "true") || !strcmp(secure, "1") || !strcasecmp(secure,