PDA

View Full Version : username question


ignoranceisblis
12-06-2004, 04:30 AM
I know how to say
$remote_user=$ENV{REMOTE_USER};
but how would I do this;
the dir /cgi-bin/users requires a user name and password
I was wondering if there was an easy way to make a file in /cgi-bin/ that can tell wether or not a the user has logged into /cgi-bin/users yet.
how could I make the file in /cgi-bin/ work like this?

$remote_user=$ENV{REMOTE_USER};
if (user has logged in to /cgi-bin/users) {
print $remote_user;
print "rest of page";
} else {
print "you have not yet logged on";
print "rest of page";
}

Any Ideas?

mlseim
12-06-2004, 01:03 PM
Use cookies...

See link below, use "cookie.lib" (cookie library) which is a helpful
script to use cookies. Have a log-in script that sets a cookie if
they successfully log-in. All scripts after that check for the correct
cookie before continuing on.

http://claree.univ-lille1.fr/~calciu/Perl/Perl_resources/Cookie/cookie-lib.html

Maybe someone knows of a better cookie library to use. This is from
around 1998? ... I've used it before, but am not sure if it stands up to
today's security.

--max--

andyede
12-06-2004, 09:48 PM
CGI module has cookie handling features if you want to do it that way.

Correct me if i'm wrong but doesn't the fact that you have a remote_user variable mean that you are logged in?

ignoranceisblis
12-07-2004, 12:44 AM
yes that is ture.
Where I'm having trouble is that the password protected folder is /cgi-bin/users
but the folder I want to be able sense a logged in user is /cgi-bin
so the user won't neccisarrily have to be logged in to view it.
How would I use the CGI cookie module?

andyede
12-07-2004, 07:24 AM
ahh ok i see what you mean. I've never used this kind of password protection. A friend of mine uses it quite successfully but he doesn't really use any CGI with it so i'm not really sure how to interface between the two and where and when the remote user data is availiable. By the fact you are having problems I assume it only availiale in the directory that it was set in?

i've always use the cookie option, problem is it requires alot more work because you have to write a script to handle the logins and logging in/out etc. If you can write yourself a good script though you can use it over and over again in other sites you make.

if you want to know more about CGI module and cookies then here (http://search.cpan.org/~lds/CGI.pm-3.05/CGI.pm#HTTP_COOKIES) is a good place to look

the CGI module is great I use it in almost every cgi i write. It comes with perl packages so you should already have it unless you have a VERY old version and you can rely on most web servers having it. well worth reading up on if you don't use it already. I think theres even a book on how to use it.

ignoranceisblis
12-07-2004, 06:43 PM
Thank you very much.
I clicked your link and it was very informative.
I only actually started getting into CGI/perl about a month and a half ago, but this forum has been a great place to learn the proper references.
Thanks you the continued support