in reply to Re^3: Perl CGI Cookies "Content-Type:text/html" showing at top of html.
in thread Perl CGI Cookies "Content-Type:text/html" showing at top of html.

Ahh yep I see why it is happening, However to set my cookie correctly I must print the cookie into the header(or so ive read); print header(-cookie=>$cookie); and for the html to work correctly I need to print  print "Content-type:text/html\n\n"; so how do I fix this?

Replies are listed 'Best First'.
Re^5: Perl CGI Cookies "Content-Type:text/html" showing at top of html.
by Anonymous Monk on Aug 19, 2011 at 12:15 UTC

    I must print the cookie into the h....and for the html to work correctly I need

    Kindly go back to the manuals I linked :)

    You can only print the header once, and once only, this is the rule of HTTP, no way around it

    Instead of broken logic

    if ( blah ){ print header( and cookie ); } print header;
    use correct logic for print headers only once
    if ( blah ){ store cookie in variable } print header ( and $cookie )