Re: WWW-Authenticate question!

2002-08-13 Thread Gerald R. Jensen

Jerry:

This is really off-topic for this forum, but why not set a cookie with a
short life (expiration). Each page can check for the valid cookie. Then in
your logout page, delete the cookie.

Gerald Jensen

- Original Message -
From: JeRRy [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, August 12, 2002 10:52 PM
Subject: WWW-Authenticate question!


Hi,

I am using the following code for a username /
password combination.  A java box appears which the
user needs to input a username/password.  This works
fine, BUT how do I make it so if the user wishes to
logout they can?  I've tried closing the browser on
many browsers but on some you remain logged in even
when you visit the site again, resetting the PC works
to logout but really is not what I want.  I would
prefer a logout button/link to clear their session
out.  Here is my code below:

?
function auth () {
Header(WWW-Authenticate: Basic realm=\ArmFN
public
site\);
Header(HTTP/1.0 401 Unauthorized);
echo You have to authentificate yourself
first \n;
exit;

}

mysql_connect(localhost,USERMAME,PASSWORD) or
die(Unable to connect to SQL server);
mysql_select_db( MY_db) or die( Unable to select
database);

if(!isset($PHP_AUTH_USER)) {

$timeout =
mktime(date(G),date(i)+10,0,date(m),date(d),date(Y));
mysql_query(update users set id='$timeout' where
user='$user' and
password='$pass') or die(k1);

auth();

} else {

$pass = $PHP_AUTH_PW;
$user = $PHP_AUTH_USER;

$nowtime =
mktime(date(G),date(i),0,date(m),date(d),date(Y));
$quer2 = mysql_query(select * from contacts where
user='$user' and
Password='$pass' and id  '$nowtime') or die(kuk2);
if (mysql_num_rows($quer2) == 0) {
$timeout =
mktime(date(G),date(i)+10,0,date(m),date(d),date(Y));
mysql_query(update contacts set id='$timeout' where
user='$user' and
password='$pass') or die(k);

auth();
}
}
?


ALSO, if I have more than one page for the members how
do I protect these?  So if they have not got a valid
login they get asked for it or referred back to the
login / main page?  Or is there a way to have all my
pages in the one PHP file?  (I think this is possible
somehow)

Thankyou!

Jerry

http://digital.yahoo.com.au - Yahoo! Digital How To
- Get the best out of your PC!

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail
[EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php





-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




WWW-Authenticate question!

2002-08-12 Thread JeRRy

Hi,

I am using the following code for a username /
password combination.  A java box appears which the
user needs to input a username/password.  This works
fine, BUT how do I make it so if the user wishes to
logout they can?  I've tried closing the browser on
many browsers but on some you remain logged in even
when you visit the site again, resetting the PC works
to logout but really is not what I want.  I would
prefer a logout button/link to clear their session
out.  Here is my code below:

?
function auth () {
Header(WWW-Authenticate: Basic realm=\ArmFN
public
site\);
Header(HTTP/1.0 401 Unauthorized);
echo You have to authentificate yourself
first \n;
exit;

}

mysql_connect(localhost,USERMAME,PASSWORD) or
die(Unable to connect to SQL server); 
mysql_select_db( MY_db) or die( Unable to select
database); 

if(!isset($PHP_AUTH_USER)) {

$timeout =
mktime(date(G),date(i)+10,0,date(m),date(d),date(Y));
mysql_query(update users set id='$timeout' where
user='$user' and
password='$pass') or die(k1);

auth();

} else {

$pass = $PHP_AUTH_PW;
$user = $PHP_AUTH_USER;

$nowtime =
mktime(date(G),date(i),0,date(m),date(d),date(Y));
$quer2 = mysql_query(select * from contacts where
user='$user' and
Password='$pass' and id  '$nowtime') or die(kuk2);
if (mysql_num_rows($quer2) == 0) {
$timeout =
mktime(date(G),date(i)+10,0,date(m),date(d),date(Y));
mysql_query(update contacts set id='$timeout' where
user='$user' and
password='$pass') or die(k);

auth();
}
}
?


ALSO, if I have more than one page for the members how
do I protect these?  So if they have not got a valid
login they get asked for it or referred back to the
login / main page?  Or is there a way to have all my
pages in the one PHP file?  (I think this is possible
somehow)

Thankyou!

Jerry

http://digital.yahoo.com.au - Yahoo! Digital How To
- Get the best out of your PC!

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php