I have a problem with my remember me php function. For some reason it works perfectly in Firefox but not in IE8. I suspect it's something to do with the checkbox? IE seems to automatically remember the user even if the checkbox remains unchecked! So a cookie is set when the checkbox is checked AND when it's unchecked! Please see the code below. How can i make this work in IE8? Any help will be much appreciated.

<?php

include 'functions.php';

if(loggedin())
	{
	header("location:userarea.php");
	exit();
	}

if($_POST['login'])
{

//get data
$username = $_POST['username'];
$password = $_POST['password'];
$rememberme = $_POST['rememberme'];

if($username&&$password)
{

$login = mysql_query("SELECT * FROM users WHERE username='$username'");
while($row=mysql_fetch_assoc($login))
	{

	$db_password = $row['password'];
	if(md5($password)==$db_password)
		$loginok = TRUE;
	else
		$loginok = FALSE;
		
	if($loginok==TRUE)
		{
		
		if($rememberme=='yes')
			setcookie("username", $username, time()+7200);
			else if($rememberme=='')
				$_SESSION['username']=$username;
		
			header("location:userarea.php");
			exit();
		}
		else
			die("Incorrect username/password combination.");

	}

}
else
	die("Please enter a username/password");

}


?>

<form action="loginb.php" method="post">
Username: <br />
<input type="text" name="username"><p />
Pasword: <br />
<input type="password" name="password"><p />
<input type="checkbox" name="rememberme" value="yes"><br />
<input type="submit" name="login" value="login">
</form>

Add these at the beginning of the page:

<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.