in previous i ask a question n later worked something out myself BUT it was working fine and it doesnt, please check. Its starting and destroying a session:
loginout.php (page that logs in or out depnding on session exsistance)
<?PHP
//start a session:
session_start();
//if there is no session, mean user clicked on login button so set a session and return them to home
if (!isset($SESSION['loggedin'])) {
$SESSION['loggedin']="loggedin";
header('Refresh: 3; URL=destin.php');
print("You are now LOGGED IN. You will be redirected.");
print ($_SESSION['loggedin']); //i out this here to prove that session been set to the word loggodin
}
//else i assume user must have clicked on logout so destroy session
else {
//remove all the variables in the session
session_unset();
// destroy the session
session_destroy();
//header( 'Location: destin.php') ;
header('Refresh: 3; URL=destin.php');
print("You are now LOGGED OUT. You will be redirected.");
}
?>
menu code:
<?php
if (!isset($_SESSION['loggedin'])) {
print ("<li><a href='loginout.php' >LOG IN</a></li>");
}
else {
print ("<li><a href='loginout.php'>LOG OUT</a></li>");
}
?>
the above looks fine, and even a print statement shows that session been set to the word loggedin BUT the other pages are still assuming that session is not set yet so they keep on hiding certain features.
all my pages have a session_start(); using include