Oops, I forgot the some code:
# to set
$cookie = { -name => "foo", -value => "bar", -path => "/" };
my $data = [];
push( @$cookie_data, Apache2::Cookie->new( $r, %{$cookie} ) );
foreach ( @$cookie_data ) {
$_->bake( $r );
}
# now to unset
my $jar = Apache2::Cookie::Jar->new( $r );
my $cookies = $jar->cookies;
if ( defined $cookies->{foo} ) {
$cookie = { -name => "foo", -value => "bar", -path => "/", -expires
=> "0" };
push( @$cookie_data, Apache2::Cookie->new( $r, %{$cookie} ) );
foreach ( @$cookie_data ) {
$_->bake( $r );
}
}
On Dec 24, 2007, at 3:29 AM, Boysenberry Payne wrote:
This is what I do: $cookie = { name => "foo", value => "bar" } my $data = []; push( @$data, Apache2::Cookie->new( $r, %{$cookie} ) ); foreach ( @$data ) { $_->bake( $r ); } Hope it helps... -bop On Dec 24, 2007, at 2:55 AM, Raymond Wan wrote:Hi all, Sorry, but I'm not entirely sure if this is relevant to modperl...I was wondering if it was possible to delete cookies. I read that using Javascript, cookies can be deleted by setting it to a time in the past. I'm not sure how to do it in Mason, though. I think I know how to get a cookie and also to set a new one and send it out. But, I don't know how to get an old cookie, change it, and send it back. Or even, get a cookie, *copy it*, send the copy back. What is stopping the browser from creating a second cookie with the same name?Also, I've seen various ways of setting cookies. For example, one using APR::Request::Cookie and another using Apache2::Cookie. Which should I use? I'm setting a cookie by doing:$r->err_headers_out->add ("Set-Cookie" => $cookie->as_string);where $cookie is of type APR::Request::Cookie. Is this strange? (I forgot what I read to come up with this...most other documents mention a "bake" method...)Ray
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.