Jump to content

Recommended Posts

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.

<?php
session_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.
Link to comment
https://forums.phpfreaks.com/topic/32627-sessions-firefox-new-browser-and-php5/
Share on other sites

Yup, that doesn't work either surprisingly. Maybe revealing some more code will help:

[code]
<?php
require_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.
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.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.