Java Mailing List Archive

http://www.apache-httpd.com/

Home » modperl.perl »

Overwriting a cookie in request header

Sinha, Ritu

2009-11-17

Replies: Find Java Web Hosting

Author LoginPost Reply
I have an Apache module in which I am trying to overwrite the value of a cookie. I have tried different methods of the APR::Table without success.
Here are the approaches that I have tried:
 
[1] $r->headers_out->set("Set-Cookie", $cookie);
 
Here, $cookie has the name=value pair with the name of the cookie that needs to be overwritten. The outcome is 2 cookies with the same name.
 
[2] $cookie = $r->headers_in->{Cookie};
<search-and-replace the cookie value in $cookie>
$r->headers_out->{Cookie}=$cookie;
 
Does not do anything to the existing cookie … does not even add a new cookie.
 
[3] $cookie = $r->headers_in->{Cookie};
@cookies = split(/;/,$cookie);
$r->headers_out->clear();
< add cookies one-by-one replacing the value of the cookie in question using  $r->headers_out->set("Set-Cookie", $cookie); >
 
The web application does not work … seems like clearing the header creates problems.
 
Any pointers would be really helpful.
 
Thanks,
Ritu
 
 
 
 
©2008 apache-httpd.com - Jax Systems, LLC, U.S.A.