in reply to Re^2: 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.
if ($type eq "nme") #check the par +ameter (determines sub to be used) { $message = lmhandler::getAdd($find,$loadmap); } elsif ($type eq "addr") { $message = lmhandler::getmod($find,$loadmap); } elsif ($type eq "root") #create new coo +kie { $cookie = $query->cookie(-name=>'MY_COOKIE', -value=> $find, -expires=>'+1y', -path=>'/'); print header(-cookie=>$cookie); <-- Printing headers here ... } print "Content-type:text/html\n\n"; <--- and here. print "<html>\n"; print "<head>\n"; print "<META HTTP-EQUIV=Pragma CONTENT=no-cache>\n"; print "<META HTTP-EQUIV=Expires CONTENT=-1>\n"; print "</head>\n"; print "<title>LoadMap Browser</title>\n";
You'll have to restructure your code a bit. Printing the 'Content-type' header after calling print header(-cookie=>$cookie) counts as twice.
I'd suggest the following
if ($type eq "nme") #check the par +ameter (determines sub to be used) { $message = lmhandler::getAdd($find,$loadmap); print "Content-type:text/html\n\n"; } elsif ($type eq "addr") { $message = lmhandler::getmod($find,$loadmap); print "Content-type:text/html\n\n"; } elsif ($type eq "root") #create new coo +kie { $cookie = $query->cookie(-name=>'MY_COOKIE', -value=> $find, -expires=>'+1y', -path=>'/'); print header(-cookie=>$cookie); } print "<html>\n"; ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Perl CGI Cookies "Content-Type:text/html" showing at top of html.
by lauratheperlnewbie (Initiate) on Aug 19, 2011 at 12:01 UTC |