Known IE 8 PHP Session issue?

2020-03-30 13:42发布

问题:

I have a login system that is being authenticated via a php session. My client is saying that login is failing now that I have moved the site to a new server. But only when he uses IE 8. I have been unable to replicate these issues.

What makes it even more odd is that it all works on the previous host. I am at a loss to whether it is a browser issue, the server change or anything else.

Are there any know issues? I thought it may be a header("location: ") issue, but it seemingly is working on the previous host.

Any help appreciated

The login code is this (It keeps returning my client to index.php?invalid even though he says he is entering the correct login details and I am able to access with no problem.

<?php
require('includes/functions.php');
require('includes/db.php');

$user=clean($_POST[user]);
$pass=clean($_POST[pass]);

$qry="SELECT id FROM table WHERE userfield='$user' 
AND passwordfield='".md5($pass)."'";

$result=mysql_query($qry);

if(mysql_num_rows($result)>0) {
    //Login Successful
    //Regenerate session ID to
    //prevent session fixation attacks
    session_start();
    session_regenerate_id();
    $result=mysql_fetch_assoc($result);
    $_SESSION['USER']=$result['id'];
    //Write session to disc
    session_write_close();
    header("location: success.php");
    exit();
}
    header("location: index.php?invalid");
?>

回答1:

Yes, IE8 has this problem with session cookies, especially when redirects are used. Try putting session_set_cookie_params(0); prior to starting the session - this would ensure that the session cookie will not expire until the browser is closed.