Forum Moderators: coopster & phranque

Message Too Old, No Replies

Set-Cookie

         

reubensant

12:28 am on Jun 29, 2005 (gmt 0)

10+ Year Member



Hi,

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

moltar

8:07 pm on Jun 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You cannot set the cookie you already started
print
ing.

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;