perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Peters <>
Subject Re: Updating cookies in header during request processing
Date Fri, 18 Sep 2009 13:28:49 GMT
On 09/18/2009 09:14 AM, Igor Chudov wrote:

> I realized that there is something I am missing. Sometimes I may need to
> put something into the session after I did $cgi->start_html. I can do it
> if the cookie is only a session ID, with session data stored in mysql.

This might be a larger architectural problem them. IMO, you really 
shouldn't use for HTML generation. Most people use a template of 
some sort for that.

And the next thing would be to reorganize your code so that you aren't 
tied to a specific order of doing things. For instance, I normally use 
CGI::Application which lets me do all kinds of things to the headers and 
content until I'm all ready to return at the end of my run mode. The 
order doesn't matter.

> But how can I change the cookie AFTER I called $cgi->start_html?

Since cookies are part of the HTTP headers they need to go out before 
any HTML content. So instead of just printing the content as you go, why 
don't you collect your HTML into a variable and then print it all out at 
the end.

Michael Peters
Plus Three, LP

View raw message