If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > User authentication - problem with refresh

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-04-05, 16:24
juroh juroh is offline
Registered User
 
Join Date: Feb 2005
Posts: 1
User authentication - problem with refresh

Hi guys,

I don't find here any answer for my problem, so I'm posting request here, if it's possible, pls help me.

I'm creating user authentication system in PHP based on sessions.
When user log in, it's adding a row to MySQL database's table with his SID and Timeout ( actually time + time out constant ). At the head of each script is a row, which has to delete all records from table, where timeout is lower than actualy time. Everythink is working well until user click to back button and refresh the site. I though, there is no records in table, so he cann't see the protected page, but it doesn't work.

here is the code, pls advice what wrong ... thx, JuroH

<?
Header("Pragma: No-cache");
Header("Cache-Control: No-cache, Must-revalidate");
Header("Expires: ".GMDate("D, d M Y H:i:s")." GMT");


include 'conn.php';

$timeout = time()+$t_out;
MySQL_Query("DELETE FROM autorizace WHERE time < time()");

If ((IsSet($login)) AND (IsSet($password))):
$p = MD5($password);
$MSQ = MySQL_Query("SELECT * FROM users WHERE (login LIKE '$login') AND (password LIKE '$p')");

If (MySQL_Num_Rows($MSQ) <> 1):
unset($login);
unset($password);
header("location: index.php?login_error=1");

Exit;

Else:
$SN = "authentication";
Session_name("$SN");
Session_start();
$sid = Session_id();

$MSQ = MySQL_Query("SELECT * FROM autorizace WHERE (id = '$sid') AND (time < '$timeout')");

If ((MySQL_Num_Rows($MSQ) <> 1) and ($send <> "true")):
echo "Neautorizovaný přístuttp ";
echo $send;
Exit;
Else:
$MSQ = MySQL_Query("INSERT INTO autorizace VALUES ('$sid', time()");
Endif;

Endif;
$send="false";
?>
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On