Brendan Posted January 2, 2007 Share Posted January 2, 2007 For some reason php5 and Firefox don't seem to get along when it comes to sessions. I have finally gotten them to start, but can't seem to destroy them. I have put the following code into a script named logout.php.<?phpsession_start();session_unset();session_destroy();$http_host=$_SERVER["HTTP_HOST"];header ("Location: http://$http_host/index.php");?>Yet when i try to login with a different username, the old username is still logged in. Also, when i go back to a page after logging out it is still loaded when it should redirect to the login page.How about a simple solution, anyone? Perhaps i am overlooking something. Quote Link to comment https://forums.phpfreaks.com/topic/32627-sessions-firefox-new-browser-and-php5/ Share on other sites More sharing options...
Philip Posted January 2, 2007 Share Posted January 2, 2007 Im doing session_destroy(); with my logout script and running php5 & ff, and it works fine.Have you tried just plain old: unset($_SESSION['variable']); ? Quote Link to comment https://forums.phpfreaks.com/topic/32627-sessions-firefox-new-browser-and-php5/#findComment-151785 Share on other sites More sharing options...
Brendan Posted January 3, 2007 Author Share Posted January 3, 2007 Yup, that doesn't work either surprisingly. Maybe revealing some more code will help:[code]<?phprequire_once 'script.php which initiates session_start() and mysql'$php_self=$_SERVER['PHP_SELF'];$http_host=$_SERVER['HTTP_HOST'];$loginusername=$_POST["loginusername"];$password=$_POST["password"];$submit=$_POST["submit"];$userid=$_SESSION["userid"];if($submit){$sqllog=mysql_query("SQL Query, this part is tested and works; the results are correct ");$row=mysql_fetch_array($sqllog);$num=mysql_num_rows($sqllog);if($num==1){$_SESSION["userid"]=$row["id"]; header ("Location: http://$http_host/login/userhomepage.php"); } else { header ("Location: log_in.php?status=wrongid"); } }if (!isset($_SESSION["userid"]) or empty($_SESSION["userid"])) { session_write_close();header ("Location:http://$http_host/login/logout.php");}if (isset($_SESSION["userid"]) and !empty($_SESSION["userid"])) { $sql=mysql_query("Sql query to select user'");if(!empty($sql)){$row=mysql_fetch_array($sql);$username=$row["username"];$_SESSION["viewuser"]=$row["username"];}}?>[/code]This code is included in every members-only page. Quote Link to comment https://forums.phpfreaks.com/topic/32627-sessions-firefox-new-browser-and-php5/#findComment-151798 Share on other sites More sharing options...
trq Posted January 3, 2007 Share Posted January 3, 2007 PHP runs on the server well before it ever gets to any browser. there may be a setting in FF which is cahing the pages or something though. Quote Link to comment https://forums.phpfreaks.com/topic/32627-sessions-firefox-new-browser-and-php5/#findComment-151874 Share on other sites More sharing options...
PFMaBiSmAd Posted January 3, 2007 Share Posted January 3, 2007 Place an [b]exit;[/b] statement following each header(...) redirect statement. This will prevent the code following the redirect from executing while the browser is requesting the new url. Quote Link to comment https://forums.phpfreaks.com/topic/32627-sessions-firefox-new-browser-and-php5/#findComment-151909 Share on other sites More sharing options...
Brendan Posted January 3, 2007 Author Share Posted January 3, 2007 That's correct, thorpe, but it is a problem with the way the new Firefox browser handles sessions. Internet Explorer handles it correctly, whereas Firefox does not. I tried adding the exit; though it simply kept me from logging in with a second username at all and instead redirected me to the login page if i had already logged in with another username. Quote Link to comment https://forums.phpfreaks.com/topic/32627-sessions-firefox-new-browser-and-php5/#findComment-152017 Share on other sites More sharing options...
corbin Posted January 3, 2007 Share Posted January 3, 2007 Try[code=php:0]$_SESSION = array();[/code] Quote Link to comment https://forums.phpfreaks.com/topic/32627-sessions-firefox-new-browser-and-php5/#findComment-152031 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.