huh! How do you know it creates another session ?
nav33n
Purple hazed!
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
Are you validating existence of session in admin's page ? Try ths simple example.
<?php //page1.php
session_start();
$_SESSION['name']="test";
echo "<a href='page2.php'>Click here</a>";
?>
This is page2.php
<?php
session_start();
if(!empty($_SESSION['name'])){
echo $_SESSION['name'];
} else {
echo "Invalid session";
}
?>
Well, if you try to access page2.php directly, you will get Invalid session. Are you doing a check like this one in admin's page ?
nav33n
Purple hazed!
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
Here is what I do
secure.php
<?php
session_start();
if (empty($_SESSION['username'])) {
header("location:index.php");
exit; }
?>
logout.php
<?php
session_start();
if($_SESSION["status"]="logged") {
session_unset();
session_destroy();
header( "Location:../index.php" );
exit();
} else {
if ($_SESSION["status"]="not logged") {
//the session variable isn't registered, the user shouldn't even be on this page
header( "Location:../index.php" );
exit();
}
}
?>
Vai
Junior Poster in Training
75 posts since Jan 2008
Reputation Points: 12
Solved Threads: 5
I'm using Mozilla Firefox. After I logged it, I checked the cookies, there will only 'YourVisitID' under localhost. Then when I press log out button, It will redirect me back to the i.dex.php. Then I tried to copy & paste the direct link to the admin's page., it still works.
Can you post your script of admin's page ? When you run the logout script, sessions should get destroyed. Check if there are still values in the session variable :S
nav33n
Purple hazed!
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
<?php
session_start();
if($_SESSION["status"]="logged") {
session_unset();
session_destroy();
header( "Location:../index.php" );
exit();
} else {
if ($_SESSION["status"]="not logged") {
//the session variable isn't registered, the user shouldn't even be on this page
header( "Location:../index.php" );
exit();
}
}
?>
Take a look at those if statements. Those are SETTING $_SESSION['status'], not comparing them. Comparisons use ==
ShawnCplus
Code Monkey
1,583 posts since Apr 2005
Reputation Points: 526
Solved Threads: 268
Maybe this isn't working. Print some statements inside this loop and execute this script (without logging in). if (!isset($_SESSION['agent']) OR ($_SESSION['agent'] != md5($_SERVER['HTTP_USER_AGENT'])) ) {
nav33n
Purple hazed!
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
Warning: session_destroy() [function.session-destroy]: Trying to destroy uninitialized session in C:\xampp\htdocs\cycle\logout.php on line 34
That means you are trying to destroy a session that doesn't exist.
nav33n
Purple hazed!
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
nav33n
Purple hazed!
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356