in reply to Re^5: CGI error: "Invalid header value contains a newline not followed by whitespace"
in thread CGI error: "Invalid header value contains a newline not followed by whitespace"

You are right, I meant browser, not apache. At any rate, on my platform, for whatever reason, your code does not result in my browsers (FF, Chrome) storing the cookies it sends. My "incorrect" code does, though; all the more reason to not trust documentation...

--EDIT--

Nevermind. Your code works actually! What can I say.

In exactly what version of CGI.pm did this behaviour change remains an open question, though. I was using the code in my OP quite satisfactorily for at least a year and a half...

  • Comment on Re^6: CGI error: "Invalid header value contains a newline not followed by whitespace"

Replies are listed 'Best First'.
Re^7: CGI error: "Invalid header value contains a newline not followed by whitespace"
by tobyink (Canon) on Feb 04, 2012 at 23:04 UTC

    Then you're probably doing something else wrong. Go to http://buzzword.org.uk/2012/ and click on redir-cookie.cgi. It will redirect you. Now check your browser's cookie jar.

    The source for redir-cookie.cgi is:

    #!/usr/bin/perl use CGI; my $cgi = CGI->new; print $cgi->redirect( -uri => "http://buzzword.org.uk/", -cookie => [ $cgi->cookie(-name=>'foobar', -value=>123) ], );

    I've tested this in Opera 12, Firefox 3.6.9, Lynx 2.8.6rel.4 and Internet Explorer 8.0. It works.