You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Brian Leech <bc...@po.cwru.edu> on 2000/06/26 22:34:47 UTC

Apache::ASP problem

Hi,

I'm trying to set a cookie from within an ASP file, by printing the 
Set-Cookie header (I have CgiHeaders set to 1).  If I follow this header 
with content, I get the following error:

Modification of a read-only value attempted at 
/usr/lib/perl5/site_perl/5.005/Apache/ASP.pm line 2969. , 
/usr/lib/perl5/site_perl/5.005/Apache/ASP.pm line 1229

However, if I follow it with a Location header, the cookie gets set, and 
the browser redirects without a problem.  If I use $Response->SetHeader in 
the same spot as the print statement, it works fine.  But I can't do this 
because I want to print the Set-Cookie header in a module, and using 
SetHeader would require me to pass the $Response object to the function in 
the module, which I don't want to do.  I've tried this with and without 
BufferingOn without any luck.  This is using Apache::ASP 0.18.  Any ideas?

Thanks,
Brian


Re: Apache::ASP problem

Posted by Joshua Chamas <jo...@chamas.com>.
Brian Leech wrote:
> 
> Hi,
> 
> I'm trying to set a cookie from within an ASP file, by printing the
> Set-Cookie header (I have CgiHeaders set to 1).  If I follow this header
> with content, I get the following error:
> 
> Modification of a read-only value attempted at
> /usr/lib/perl5/site_perl/5.005/Apache/ASP.pm line 2969. ,
> /usr/lib/perl5/site_perl/5.005/Apache/ASP.pm line 1229
> 

> However, if I follow it with a Location header, the cookie gets set, and
> the browser redirects without a problem.  If I use $Response->SetHeader in
> the same spot as the print statement, it works fine.  But I can't do this
> because I want to print the Set-Cookie header in a module, and using
> SetHeader would require me to pass the $Response object to the function in
> the module, which I don't want to do.  I've tried this with and without
> BufferingOn without any luck.  This is using Apache::ASP 0.18.  Any ideas?
> 

Why don't you try it with the $Response->{Cookies} interface?
For module work, you can always access the ASP objects via
the main:: package like:

  $main::Response->{Cookies}{some_cookie} = "some cookie value";

I think the CgiHeaders thing is dangerous, and would urge you
to stay away from it, because it will pick up any beginning
lines with : in them as headers.  I only leave the setting
in for backwards compatibility.

BTW, the main:: style notation was documented under FAQs at
http://www.nodeworks.com/asp/faq.html#How%20do%20I%20access%20the%20ASP%20Objects%20in%20general%3F

-- Joshua