Código PHP:
if (isset($_GET['logout']))
{
setcookie('user','0',time() - (60*60*24*365),'/');
unset($_COOKIE['user']);
$_SESSION['user'] = '0';
$_SESSION = array();
session_destroy();
}
elseif (isset($_SESSION['user']))
{
setcookie('user',$_SESSION['user'],time() + (60*60*24*365),'/');
}