Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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 => "https://secure.domain.net/cgi-bin/coo +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: https://secure.domain.net/cgi-bin/ctladm.cgi\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),

Spacewarp

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.


    _______________
    DamnDirtyApe
    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...

      Spacewarp

      DISCLAIMER:
      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 CGI.pm:

    print $q->header();

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

    Michele.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2014-07-11 22:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (235 votes), past polls