problem with logout script in php

Posted by user225269 on Stack Overflow See other posts from Stack Overflow or by user225269
Published on 2010-04-08T05:16:31Z Indexed on 2010/04/08 5:23 UTC
Read the original article Hit count: 169

Filed under:
|
|

I'm a beginner in php, and I am trying to create a login and logout. But I am having problems in logging out. My logout just calls for the login form which is this:

<?
session_start();
session_destroy();
?>
<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form name="form1" method="post" action="checklogin.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="3"><strong>Member Login </strong></td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input name="myusername" type="text" id="myusername"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="mypassword" type="text" id="mypassword"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>

My problem is, when I try to press the back button in the browser. Whoever user is using it can still access what is not supposed to be accessed when a user hasn't logged in. Do I need to add a code on the user page? I have this code on the user page:

<? 
session_start();
if(!session_is_registered(myusername)){
header("location:main_login.php");
}
?>

What can you recommend that I would do so that a script will prompt to enter the username and password again when a user clicks on the back button.

© Stack Overflow or respective owner

Related posts about php

Related posts about html