Jump to content

Sessions - Firefox New Browser and PHP5


Brendan

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.