Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Login Info...

Status
Not open for further replies.

perlone

Programmer
May 20, 2001
438
US
Hi,

I have a page called index.html. This where the user logins with their username and password. On my script login.cgi, it will check to see if the user exist or not. Here's half of my code:

#info from the html code #



if (-e "$basedir/$FORM{'email'}) {
&log2;
}else{
#no user
}

sub log 2 {
open(F, "$basedir/$FORM{'email'}/stats.txt");
@stats = <F>;
close(F);

foreach $stats (@stats)
{
chomp($stats);
($username,$gold, $points, $level, $status, $gender, $email, $pass, $version)=split(/\|/,$stats);
}

if ($FORM{'pass'} eq $pass) {
#and so on.... (you got the idea)
}
}

The first login page works perfectly fine and when the user click on the link and goes to another page, all the info is gone. All the url's are like this: login.cgi?email=$email&pass=$pass. If they goes something like login.cgi?email=$email&pass=$pass&STORE, all the stats are gone. I don't know how to pass this info from that HTML page (index.html) to other pages. Anyone have a clue what i'm talking about? Thanks again for your time.

-Aaron


 
Well, the reason that the stats are gone is because they are being passed by GET and the browser does not retain them in memory.

One way to fix this would be to store the username and password (and all that other stuff) in a cookie.

This is easily done, and I think that goBoating has written several FAQ's, if not in this forum, then in the CGI one.

You can store all of that data in a cookie, then when the user leaves, delete the cookie off their computer.

This is referred to as session managment. And, if you don't mind me saying, it is really easy to do in PHP, and a lot more secure as well.

You could head over to the PHP forum to learn how to do session management. PHP is almost like Perl, with a few exceptions and a lot more functions, and I suggest you check it out one time.

Hope this helps.


-Vic vic cherubini
krs-one@cnunited.com
====
Knows: Perl, HTML, JavScript, C/C++, PHP, Flash
====
 
ya but sometimes the user refuse the cookies. I'll also try the PHP.
 
I run a forum (constantly in development)
the setup program, which requires user auth, runs in perl
Basically everything i run, uses a form
Using hidden inputs, i write the user name and password to hidden inputs in the form i'm using, call them the same as i did before, and then check user auth on loading of the next script, its very handy when you can put multiple functions on one script, the setup program uses one perl file, and the same for is elsefor the login check on every command.

so basically:

write the iuser name and password used by the user on log in to hidden form elemtns, then use the same script to execute all the commandsthey'll need during the session, that way you can pass any varible from page to page with no problems

Hope this helps
Sib
Siberdude
siberdude@settlers.co.uk
 
You could keep all the information server-side, and use an encrypted session id. The code would be slightly in depth... if PHP doesn't work out for you, I might be able to whip some up for you. <p>Liam Morley<br><A HREF="mailto:"></A><br>&quot;light the deep, and bring silence to the world.<br>light the world, and bring depth to the silence.&quot;
 
any &quot;transactions&quot; (computations) made on the server are called server-side transactions.. anything done by the browser or by the user's computer is a &quot;client-side transaction&quot;. Because a cookie is kept on the person's computer (and not on the server), it's client-side (on the side of the client); if you were to keep the information in a database of some sort (either a text file or a more fully functional database, maybe MySQL), you wouldn't need to use cookies. <p>Liam Morley<br><A HREF="mailto:"></A><br>&quot;light the deep, and bring silence to the world.<br>light the world, and bring depth to the silence.&quot;
 
ok, I saved all user files in to a text-based database and i'm moving those to MySQL.
 
cool, best of luck. don't hesitate to use the forums if you get stuck. :eek:) <p>Liam Morley<br><A HREF="mailto:"></A><br>&quot;light the deep, and bring silence to the world.<br>light the world, and bring depth to the silence.&quot;
 
One little program. You see, i'm real a newbie to this sql stuff. I downloaded the latest version of MySQL and i did the configuration with MySQL Admin. But still, i don't know how to connect this to perl. Do you knows it? I knows sql commands but cannot connect them to perl.
 
Imotic,

Could you point me in the direction of the encrypted session ID information for Perl? I'm very interested in learning about this functionality for some web tools I create in the office.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top