imarockstar Posted September 17, 2008 Share Posted September 17, 2008 For some reason ... my sessions are not clearing .. is there anything wrong with this ... <?php if (isset($_SESSION['username'])){ //echo "User : ".$_SESSION['username']; session_destroy(); echo " <div class=deleted> You have been logged out of the job board ! </div> "; } else { echo "Please log back into the admin section."; } ?> Link to comment https://forums.phpfreaks.com/topic/124688-session-help/ Share on other sites More sharing options...
HeaDmiLe Posted September 17, 2008 Share Posted September 17, 2008 I think there is no way to use session_destroy without session_start... did you tested if script passes if condition? Link to comment https://forums.phpfreaks.com/topic/124688-session-help/#findComment-644017 Share on other sites More sharing options...
imarockstar Posted September 17, 2008 Author Share Posted September 17, 2008 sorry i should of gave you the full code .... I am using start session ... whats wierd that this works fine on my nix box .. .but when i put it on a windows server . it doest work .. <?php session_start(); $pgTitle = "Technology Staffing Services"; $pgMetaDescription = "Technology Staffing Services"; $pgMetaKeywords = "Technology Staffing Services"; $pgHead = ""; $style = 2; include("includes/head.php"); include("includes/connect.php"); ?> <?php include("includes/header.php"); ?> <?php include("includes/nav.php"); ?> <?php include("includes/slider.php"); ?> <!-- interior content wrapper start #intwrapper --> <div class=intwrapper> <!-- left side start #leftside --> <div class='leftside body'> <h2 class=>Admin Logout</h2> <?php if (isset($_SESSION['username'])){ //echo "User : ".$_SESSION['username']; unset($_SESSION['username']); echo " <div class=deleted> You have been logged out of the job board ! </div> "; } else { echo "Please log back into the admin section."; } ?> <br><bR> <a href='admin_login.php'>log back in</a> </div> <!-- #leftside --> <?php include("includes/sidebaradmin.php"); ?> <?php include("includes/footer.php"); ?> Link to comment https://forums.phpfreaks.com/topic/124688-session-help/#findComment-644022 Share on other sites More sharing options...
HeaDmiLe Posted September 17, 2008 Share Posted September 17, 2008 put print_r($_SESSION); line before if condition if(isset[$_SESSION.... Link to comment https://forums.phpfreaks.com/topic/124688-session-help/#findComment-644026 Share on other sites More sharing options...
imarockstar Posted September 17, 2008 Author Share Posted September 17, 2008 nope .. its still saying im logged in ... i hve to clear the COOKIES for it to log me out .. but im not setting cookies ... this is wierd ... worked fine but then I through it on a windows server .. and blah .. Link to comment https://forums.phpfreaks.com/topic/124688-session-help/#findComment-644045 Share on other sites More sharing options...
HeaDmiLe Posted September 17, 2008 Share Posted September 17, 2008 please copy the output of print_r($_SESSION); if there is sth or just a blank? Link to comment https://forums.phpfreaks.com/topic/124688-session-help/#findComment-644050 Share on other sites More sharing options...
imarockstar Posted September 17, 2008 Author Share Posted September 17, 2008 Array ( [recid] => 6223430 ) thats what im getting Link to comment https://forums.phpfreaks.com/topic/124688-session-help/#findComment-644060 Share on other sites More sharing options...
HeaDmiLe Posted September 17, 2008 Share Posted September 17, 2008 that means that username is not set really... problem is somewhere before this script... username isn't stored into session Link to comment https://forums.phpfreaks.com/topic/124688-session-help/#findComment-644066 Share on other sites More sharing options...
PFMaBiSmAd Posted September 17, 2008 Share Posted September 17, 2008 The posted code appears to have a newline before the <?php tag. That content would prevent a session from starting, also preventing it from being destroyed. Add the following two lines immediately after your <?php tag - ini_set ("display_errors", "1"); error_reporting(E_ALL); Link to comment https://forums.phpfreaks.com/topic/124688-session-help/#findComment-644092 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.