So i've posted this question elsewhere but haven't found any suitable answers yet.
I'm trying to create a website found here - r3gamers.com (you can head there to test this problem if you want). I've created a login page which works (as far as i can tell, properly) using cookies.
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
require_once ('LoginFunctions.inc.php');
require_once ('Connection.php');
list ($check, $data) = check_login($dbc, $_POST['Username'], $_POST['Password']);
if ($check) {
setcookie('Username', $data['Username'], time()+60*60*24*90, '/', '', 0, 0);
header('Location: index.php');
} else {
$errors = $data;
}
}
include('LoginPage.inc.php')
?>
This is the page that is giving me a problem though, the logout page.
<?php
require_once ('Connection.php');
header('Refresh: 0;');
if (!isset($_COOKIE['Username'])){
header('Location: LoginFunctions.php');
} else {
setcookie('Username', '', time()-60*60*24*90, '/', '', 0, 0);
unset($_COOKIE['Username']);
header('Location: index.php');
}
?> As far as i can tell, i'm both setting and unsetting the cookie properly, however the cookie never deletes. It always stays active.
It's worth mentioning that this problem only occurs on my live domain (hosted through godaddy.com). When testing this through netbeans, it works fine. The problem occurs on all web browsers too.
"Solutions" that have been given but ineffective so far have been -
Set value to null
Set path to '/'
Redirect using an HTML header, rather than php header.
None of these worked, all leaving me with the same problem; that i either don't log out at all or that i log out only on the redirected page but the cookie is never deleted, so on the next page the cookie takes effect again.
I've been trying to solve this for a couple days now but had no luck. I could really do with some help.