Hi, I have created a page that upon clicking a url link on the page if the url has a cookie session then it should take user to the page OR if theres no session cookie it opens a new page. This new page requires user to type their user name and password and then post the page upon submitting. If the user gets their details right then it should take them to the page dependent on link clicked, if not it will bring up a 2nd warning of incorrect password try again and just stays in this state till you log in correct details. The problem I am getting is this: 1) when I have typed in correct user details it does bring up the page I required, however, if i click on the link for the page again AFTER user details are already confirmed and cookie is added it seems to take me to a blank page. 2) WHen I close the login window and click on the link for the gallery page I want it also brings me a blank page.
Reading in browser cookie script > sub getcookies{ $cookies = $ENV{'HTTP_COOKIE'}; @allcookies = split(/;\s*/,$cookies); foreach $i (@allcookies){ ($name,$value) = split(/\s*=\s*/,$i); $cookie{$name}=$value; } } PAge to read target URL INTO PAGE > sub gethtml { open (DATA,"text file DB location"); @DB=<DATA>; close (DATA); foreach $rec (@DB){ chomp($rec); ($token,$file)=split(/\t/,$rec); if ($input{'target'} eq $token) { $url = $file; } } open (HTML, "$url"); @PAGE=<HTML>; close (HTML); } Read in user data and check for valid username/password pair >>>>> sub idcheck { open (DATA,"<$DATABASE"); @DB=<DATA>; close (DATA); $valid = 0; foreach $rec (@DB){ chomp($rec); ($username,$password,$name,$email,$degree)=split(/\t/,$rec); $username = uc $username; $input{'user'} = uc $input{'user'}; if (($input{'user'} eq $username) && ($input{'pass'} eq $pass +word)) { $valid = 1; if ($input{'user'} eq "0") { $valid = 0; } } } return $valid; } >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> PArsing the form data >>>>> sub parseform { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); $buffer =~ tr/+/ /; @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg +; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/e +g; $FORM{$name} = $value; } return %FORM; } if (&idcheck) { &gethtml; print "Content-type:text/html\n"; print "Set-Cookie: User=OK; domain=domain name; \n\n"; print @PAGE; exit; } else { &getcookies; if ($cookie{'User'} eq "OK") { &gethtml; print "Content-type: text/html\n\n"; print @PAGE; exit; }
Sorry to bombard so much code here... Basically, I am really confused as to whether its the cookie problem or the post problem? will I need to use GET instead? It seems that after the gallery link page it loses the variables storing the target for the page causing the return of the blank page. Can anyone help??? Thanks for any help you can give me.

In reply to Cookie Problem by lovely

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.