Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I am currently working on a cgi-script, which takes a username and password, checks to see if it is right, encripts it (not in this because I'm unsure of what encription I can use), and send the encripted username + sessionid to a cookie

I've checked everything, and only the cookie isn't working. Before someone asks I check for the cookie using 4 methods: in IE and Mozilla turned on prompting and wasn't, in IE searched entire computer for *.txt, in Mozilla looked at cookie organizer, and sent cookie to screen, it showed up just fine. So any ideas on why the cookie dosen't work, and other input on general coding, would be appricated.

#!/usr/bin/perl -wT use strict; use CGI; use CGI::Cookie; my $query = new CGI; my $good_user = ""; my $good_pass = ""; my $real_user = ""; my $real_pass = ""; my $itis = ""; use vars qw($incuser $incpass); &url if $query ->request_method() eq "GET"; my $pword_file = "/location/of/file/.password"; #will use database later but for now keep file my $userid_entd = $query->param('incuser'); my $pword_entd = $query->param('incpass'); $userid_entd =~ tr/A-Z/a-z/; $pword_entd =~tr/A-Z/a-z/; &url if $userid_entd =~ /[^0-9a-z]/; &url if $userid_entd eq ""; $good_user = $userid_entd; &url if $pword_entd =~ /[^0-9a-z]/; &url if $pword_entd eq ""; $good_pass = $pword_entd;
open (USERFILE, $pword_file) || die "File cannot open"; while (<USERFILE>) { chomp; ($real_user, $real_pass) = split /\|/; if ($real_user eq $good_user && $real_pass eq $good_pass) { my $stime = time; my $c = $query->cookie( -name => 'ID', -value => "${stime}${good_user}99", -expires => '+1h', -domain => '', -path => '/some/path', ); print $query->header( -cookie => $c); # print "Set-Cookie: $c\n"; #this was tried, also didn't work $itis="good"; &url; } } close (USERFILE); &url; #&url prints a header and checks to see if $itis eq "good" #print one message if it is another if it isn't

"Pain is weakness leaving the body, I find myself in pain everyday" -me

In reply to Problem setting cookie using CGI::Cookie by kutsu

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-05-19 08:27 GMT
Find Nodes?
    Voting Booth?

    No recent polls found