httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sorin Manolache <>
Subject Re: How to *add* a cookie in module?
Date Tue, 19 Jun 2012 07:24:24 GMT
On 2012-06-19 07:26, wrote:
> Hi,
> I spoke too soon :(....  The apr_table_mergen puts a comma (",") in between each cookie
name/value pair, rather than a semicolon (";").
> So, does anyone know how I can accomplish the merge of the cookie headers, but with semicolons
in between the name/value pairs?

AFAIK there's no direct way to add a cookie to the Cookie request 
header. If you're sure that you already have a Cookie request header, 
you can use the "RequestHeader edit" directive (RequestHeader edit 
Cookie ".*" "$1; my_cookie"). However, afaik there's no directive 
implementing something like if_present_edit_else_set.

You'll have to do it manually:

const char *cookie = apr_table_get(r->headers_in, "Cookie");
if (cookie == NULL)
    apr_table_set(r->headers_in, "Cookie", my_cookie);
    apr_table_setn(r->headers_in, "Cookie", apr_pstrcat(r->pool, cookie, 
"; ", my_cookie, NULL));


View raw message