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 => '.domain.com', -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

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.