Login Functionality Working Different on IE

Posted on 16th Feb 2014 by admin

This is an odd one, I have a site which has an admin section. The admin pages unsurprisingly require you to be logged in to access them. Each admin page has the following at the top to check that the user is logged in...

session_start();

require_once 'settings.php';

if(!isset($_SESSION['logged_in']) || empty($_SESSION['logged_in'])) {
header("Location: " . ROOT_URL);
exit();
}
On the login page the following is what occurs on a successfull login...

$_SESSION['logged_in'] = TRUE;
$_SESSION['user'] = $row['name'];
$_SESSION['id'] = $row['user_id'];
header('Location: ' . ROOT_URL . 'admin/acp.php');
exit();
If I access my site on Firefox, Chrome or Safari, the login works fine and takes me to the admin landing page of admin/acp.php, the problem occurs if you access it on Internet Explorer (ver. 8.0.6....). Upon successfull login Internet Explorer redirects to ROOT_URL and continues to redirect you there if you try and access any admin page.

To the best of my knowledge there is nothing in this code that could cause this to happen regardless of the browser used, so I feel the problem is being caused by the domain forwarding and possibly what domain the session cookie is considered active on.

Let's say our url is http://www.example.co.uk (and this is the value stored in the constant ROOT_URL). The site is hosted on a free webhost and is setup with the domain name of http://www.example.comlu.com. http://www.example.co.uk is set to forward as a frame to http://www.example.comlu.com. So I'm guessing this is causing the problem, but what I really can't understand is why it only does it in IE Any ideas or suggestions on how to fix it? I know the best solution would be to get http://www.example.co.uk's nameserver to correctly point to the webhosts nameserver and activate the url on the account, but that's not currently going to happen.

Other forums