Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

The 1st program runs, the 2nd downloads

by spacewarp (Pilgrim)
on Jun 09, 2003 at 02:40 UTC ( #264216=perlquestion: print w/ replies, xml ) Need Help??
spacewarp has asked for the wisdom of the Perl Monks concerning the following question:

Got another one for ye great and mighty monks..

I'm working through my first implementation of cookies, and hitting a major snag, even though most of my code is straight out of the CGI Programming with Perl book. On my login page, the user puts in their username and password, and it sends to the primary CGI script. That authenticates the user, and if successful, tried to set a cookie, then verify that it's been set (using, as I said, code straight out of the book).

This step:
print $q->redirect ( -url => " +kie_test.cgi", -cookie => $cookieC );
works, as does the rest of the program. In the browser, I see the cookie set attempt (using Mozilla, I purposefully deny the cookie without setting it to remember, so I can debug), but when it's given the redirect, it tries to download the cookie_test.cgi program instead of running it.

The cookie_test.cgi program:
!#/usr/bin/perl -wT # !/usr/bin/perl -wT # Originally posted typo-ed first line # Cookie Test Program for Control Panel Administration use strict; use CGI; $ENV{PATH} = "/bin:/usr/bin"; delete @ENV{ 'IFS', 'CDPATH', 'ENV', 'BASH_ENV' }; my $q = new CGI; my $sessionid = $q->cookie( -name => "C" ); if ( defined $sessionid ) { print "Location:\n\n"; } else { print <<AAA; Content-type: text/html ### Html error message cut out ### AAA ; } exit;
Anyone know what's going on here?

Thanking you for your help (and your patience),


DISCLAIMER:<BR> Use of this advanced computing technology does not imply an endorsemen +t<BR> of Western industrial civilization.<BR>

Updated #! line per author's req. - dvergin 2003-06-08

Comment on The 1st program runs, the 2nd downloads
Select or Download Code
Re: The 1st program runs, the 2nd downloads
by DamnDirtyApe (Curate) on Jun 09, 2003 at 03:55 UTC

    Your perl shebang is missing the leading # on the first line. I'd fix that and give it another try.

    Those who know that they are profound strive for clarity. Those who
    would like to seem profound to the crowd strive for obscurity.
                --Friedrich Nietzsche
      That's been pointed out to me, and is a typo in my post, not my program (didn't copy fully)

      Now, if I could just remember how to update my question...


      Use of this advanced computing technology does not imply an endorsement
      of Western industrial civilization.
Re: The 1st program runs, the 2nd downloads
by arthas (Hermit) on Jun 09, 2003 at 08:27 UTC

    The code you posted works all right on my computer. The only thing I could suggest you is to try outputting the header (in cookie_test.cgi) using

    print $q->header();

    instead of doing it by hand, which should however work as well.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://264216]
Approved by vek
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (9)
As of 2014-07-31 11:29 GMT
Find Nodes?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:

    Results (248 votes), past polls