Posts: 106
Location: South Wales, UK
|
Hey all. I have a cookie being set when a user logs in and when they logout the cookie is supposed to be ended.
Here is the start (login):
PHP Code:
//Collect the details and validate
$time = time();
$pass = md5($password);
$sql = mysql_query("SELECT * FROM members WHERE username='$username' AND password='$password'") or die(mysql_error());
$count = mysql_num_rows($sql);
if ($count > 0)
{
$cookie_data = $username.'-'.$pass;
setcookie ("cookie_info",$cookie_data, $time+1800);
header("Location: home.php");
And the end (logout):
PHP Code:
<?php
$time = time();
if (isset($_COOKIE['cookie_info']))
{
setcookie ("cookie_info", "", $time - 1800);
?>
<font face="Verdana" size="2" color="FF0000"><?php echo "Logged Out"; ?></font>
<?php
}
?>
I got this from phpfreaks.com when I first started learning php. But the cookie doesn't seem to end and doesn't log out th user.
Anyone able to help?
Thanks in advance,
Manson
|