Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Problems? Is your data what you think it is?
 
PerlMonks  

Re: CGI error: "Invalid header value contains a newline not followed by whitespace"

by InfiniteSilence (Deacon)
on Feb 04, 2012 at 03:53 UTC ( #951756=note: print w/ replies, xml ) Need Help??


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

Works for me once you define the variables being passed into the cookie method.

#!/usr/bin/perl -w use strict; use CGI; use CGI::Cookie; my $q = CGI->new(); my ($username, $secret) = ('wowza','special'); my $set_username = $q->cookie( -name => "user_name", -value => $username, -expires => "+1d", ); my $set_session = $q->cookie( -name => "session", -value => $secret, -expires => "+1d", ); print $q->header( -cookie=>[$set_session, $set_username], $q->redirect +(q|http://www.google.com/|)); #print $q->header(); print $q->html($q->body($q->h1('hi there'))); 1;

Celebrate Intellectual Diversity


Comment on Re: CGI error: "Invalid header value contains a newline not followed by whitespace"
Download Code
Re^2: CGI error: "Invalid header value contains a newline not followed by whitespace"
by MyMonkName (Acolyte) on Feb 04, 2012 at 04:00 UTC

    What version of Perl and apache have you?

    Thanks!
Re^2: CGI error: "Invalid header value contains a newline not followed by whitespace"
by MyMonkName (Acolyte) on Feb 04, 2012 at 06:47 UTC

    I may not have been clear enough in my earlier reply. What I mean to say is: your code throws the same error on my configuration, and so it sounds like the new version of CGI.pm disallows whatever I was used to doing. I hope to understand the issue (sounds like a security precaution) and fix it rather than blindly backing out of the newer version of the CGI library.

    Thanks!
      You call header() and redirect(), but redirect() itself calls header(), and in HTTP you only print headers once

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://951756]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (14)
As of 2014-04-16 20:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (433 votes), past polls