Messing with what headers are actually printed with certain functions like header() and redirect()
redirect("http://www.example.com »")
print redirect("http://www.example.com");
outputs
Status: 302 Moved Location: http://www.example.com
Note, each line of the header ends with a line ending, except the Location: part which ends in two line endings.
header()
If you use use CGI; with my $cgi = CGI->new();, the output of
print $cgi->header();
will be,
Content-Type: text/html; charset=ISO-8859-1
which also contains two line endings at the end.
If you use use CGI::Session with my $session = CGI::Session->new();, the output of the following,
print $session->header();
will be,
Set-Cookie: CGISESSID=72151d3a108260797dab2c82ad32d021; path=/ Date: Wed, 16 Jul 2008 17:44:58 GMT Content-Type: text/html; charset=ISO-8859-1
This time a cookie is set to store your session parameters, a date was sent, and the Content-Type of text/html. The cookies name will be CGISESSID.
I actually send that cookie manually if I want to retrieve session parameters before the Content-Type: text/html is sent by setting the cookie with the following,
my $cgisession_cookie = new CGI::Cookie(-name=>'CGISESSID', -value=>$session->id); print "Set-Cookie: $cgisession_cookie\n";
Don't forget your line endings (\n) after each header line. And don't forget the last header that's printed out, like Content-Type: text/html should have two line endings.
[Click to add or edit comments])
Please prepend comments below including a date