httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <oh...@cox.net>
Subject Re: How to *add* a cookie in module?
Date Thu, 01 Jan 1970 00:00:00 GMT

---- Sorin Manolache <sorinm@gmail.com> wrote: 
> On 2012-06-19 07:26, ohaya@cox.net 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);
> else
>     apr_table_setn(r->headers_in, "Cookie", apr_pstrcat(r->pool, cookie, 
> "; ", my_cookie, NULL));
> 
> --
> Sorin
> 
> 

Sorin,

Thanks!  I kind of figured that'd be the case.  I'll give that a try later today.

Jim

Mime
View raw message