function hash_valid($db, $hash) { $query = $db->query("SELECT uid FROM hashez WHERE hash='$hash'"); if($query !== FALSE) { if(($fetch = $query->fetch(PDO::FETCH_NUM)) !== FALSE) { return current($fetch); } else { // if the cookie was invalid, unset it unset_auth_cookie(); return "invalid"; } } else { return "error"; } }
function logout() { $db = $GLOBALS['db']; $stm = $db->prepare("DELETE FROM hashez WHERE hash = :hash"); $stm->execute(array(':hash' => $_COOKIE['user'])); unset_auth_cookie(); goToApp(); }