perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Boysenberry Payne <boysenbe...@habitatlife.com>
Subject Re: Cookie questions
Date Mon, 24 Dec 2007 09:42:36 GMT
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
>>
>>
>


Mime
View raw message