Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 181
  • Last Modified:

Members area

I have mostly completed the databases in MySQL that store users infomration including "userid" and "password" - I can query this info from the database to make sure that an individual actually logs in on the log in page, but how do I carry over this information into all subsequent html pages? i.e. hold the log in over several pages, does this have anything to do with temporary cache and if so how do I use it?

0
Rusty20009
Asked:
Rusty20009
  • 3
  • 3
2 Solutions
 
venkateshwarrCommented:

You may consider the option of using sessions

http://jan.netcomp.monash.edu.au/ecommerce/perl_session.html
0
 
ahoffmannCommented:
use CGI;
my $q = new CGI;
$q->save();
# for details see man CGI
0
 
Rusty20009Author Commented:
Currently, I am attempting to set a cookie - which will, I gather, be used to authenticate the user from page to page and will expire when the user closes his/her browswer, but I do not know what is happening currently with my script- no error messages but I cannot find the cookie the gets created... does this script save a cookie to the user's browser and if so how do I gather that info on a separate php page?


$mycookie = cookie(-name => 'rusteaselogin',
               -value => $rowdata[0]);
print header(-cookie => $cookie);

0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
ahoffmannCommented:
yes the cookie is sent to the browser and stored there
you may get it back with
my $q = new CGI;
my $c = $q->->cookie('rusteaselogin');
0
 
Rusty20009Author Commented:
Sessions, cookies, variables and arrays, oh my!

I still have not been able to get my scripts to work.

a - create cookie with PERL
b - store cookie in browswer with PERL
c - redirect to new PHP webpage embedded within a CGI PERL script
d - use PHP to ascertain the contents of the cookie stored in "b" so as to act as a indication that user is logged in properly.

The Code:

if (($useridcheck =~ $rowdata[2]) && ($passwordcheck =~ $rowdata[3]))
{
$mycookie = cookie(-name => 'rusteaselogin',
-value => $rowdata[0]);
print header(-cookie => $cookie);

print "Content-type: text/html\n\n";
open (CGI, ">readcookie.php") || die ("File not created");
rename ("readcookie.php", "../readcookie.php");
print CGI << "HTML file";
      <html>
      <head>
      <title>Members Welcome Page</title>
      <link rel='stylesheet' rev='stylesheet' href='stylesheet.css' type='text/css'>
      </head>
            
      <body bgcolor=#E9E7DA>
      <center><br><br><br><br>
      <table width=650 border=0><tr><td>
      <\?
if (!isset(\$_COOKIE['rusteaselogin'])) :
SESSION_START();      
     echo "<br>". session_id();
else:
     echo "there is no cookie";
endif;
?>

      </td></tr></table><br><br>
      </center>
      </body>
      </html>

HTML file
close CGI;

print <<"CGI code";
      
      <html>
      <head>
      <title>Loading Results</title>
      <META HTTP-EQUIV="refresh" CONTENT="0; URL=http://www.my.net/readcookie.php">
      </head>
      <body>
      </body>
      </html>
      
CGI code
}

0
 
ahoffmannCommented:
> rename ("readcookie.php", "../readcookie.php");

why this?
simply do instead:

open (CGI, ">../readcookie.php") || die ("File not created");

also add at end:

close( CGI );
exit( 0 );
0
 
Rusty20009Author Commented:
It seems that my web hosting service does not have the CGI.pm module installed on their UNIX boxes... has caused much frustration, not to mention confusion.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now