hello sir ... im a little bit confuse.. what's question exactly? how to maintain a session or how to destroy it?
when i use this code Im able to enter into the website even though I logout,when I click on browsers back button
in my first program
--------------------------------------------------------------------------------------------------------------------
index.php
--------------------------------------------------------------------------------------------------------------------
<?php
session_start();
include("dbconnect.php");
if(isset($_POST['login']))
$username = $_POST['login'];
else
$username = "";
if(!empty($username))
{
if(isset($_POST['pass']))
$pas =$_POST["pass"];
$qry = <<<STR
select username,password from users where username='$username' and password='$pas';
STR;
$r=mysql_query($qry)or die(mysql_error());
$r1=mysql_fetch_assoc($r);
$rowcount=mysql_num_rows($r);
if($rowcount==1)
{
$_SESSION['username'] = $r1["username"];
?>
<script language="javascript">
document.location = "viewRecords.php";
</script>
<?php
}
else
{
print "invalid user";
}
}
?>
--------------------------------------------------------------------------------------------------------------------
view records.php
--------------------------------------------------------------------------------------------------------------------
<?php
session_start();
if(!isset($_SESSION["username"]))
{
die ("ERROR: Unauthorized access!");
}
else
{?>
<?php
function logout()
{
session_destroy();
}
?>
<td width="150" align="center" valign="middle" background="images/sub_menu.jpg"><span class="right"><a href="index.php" onClick="logout();">Logout</a></span></td>
<?php
include("dbconnect.php");
$results = mysql_query("select * from insertrecord ");
while($row = mysql_fetch_array($results))
{
echo "<tr>";
echo "<td>" . $row['jobname'] . "</td>";
echo "<td>" . $row['country'] . "</td>";
echo "<td>" . $row['city'] . "</td>";
echo "<td>" . $row['description'] . "</td>";
echo "<td>" . $row['entrydate'] . "</td>";
echo "<td>" . $row['email'] . "</td>";
echo "</tr>";
}
echo "</table>";
?>
<?php
}
?>
NOTE:this is my situation when I click on logout button I just called session destroy function.but after clicking on log out button when i select browser's back button Im able to view all the details.
regards,
ramya