I need to set a cookie in the middle of a script where the content type-header and some HTML has already been sent. Is that possible? Can I buffer the output from my perl script and return it when the full script has been executed, so if i have any set-cookie headers I will be able to output them before outputing the buffer?
Thanks in advance
To put stuff into bugger, simply store the output in the variable instead of priting it out. Then set the cookie, and print out variable contents.
my $html;
$html .= qq(<html>\n);
# the rest of the html
$html .= qq(</html>);
# set cookie
# at this step
# print out the html
print $html;