function logout_current_user() { if (isset($_SESSION["sessionid"])) { db_query("delete from {cc_session} where session='" . $_SESSION["sessionid"] . "'"); session_destroy(); } if (isset($_SESSION["user"])) { $user = $_SESSION["user"]; if ($user->id > 0) { ct_log("Logout erfolgreich: " . $user->email, 2, -1, "login"); } unset($_SESSION["user"]); } // Wenn ich mich abmelde, will ich wirklich abgemeldet sein, deshalb Cookie zur�cksetzen auf 0! setcookie("RememberMe", 0); // Nun bin ich wieder Anonym unterwegs createAnonymousUser(); }
/** * logout current user */ function logout_current_user() { if (isset($_SESSION["sessionid"])) { db_query("DELETE FROM {cc_session} WHERE session=:id", array(':id' => $_SESSION["sessionid"])); session_destroy(); } if (isset($_SESSION["user"])) { $user = $_SESSION["user"]; if ($user->id > 0) { ct_log(t('logout.successful') . ": " . $user->email, 2, -1, "login"); } //TODO use language of admin unset($_SESSION["user"]); } // on logout delete remember me cookie! setcookie("RememberMe", 0); createAnonymousUser(); }
/** * Loads the user object in the session. * * If there is no user, it will create an anymous user */ function loadUserObjectInSession() { global $q; if (!isset($_SESSION['user'])) { // Wenn nicht ausgeloggt wird und RememberMe bei der letzten Anmeldung aktiviert wurde if ($q != "logout" && isset($_COOKIE['RememberMe']) && $_COOKIE['RememberMe'] == 1) { if (isset($_COOKIE['CC_SessionId'])) { $res = db_query("SELECT * FROM {cc_session}\n WHERE session=:session AND hostname=:hostname", array(":session" => $_COOKIE['CC_SessionId'], ":hostname" => $_SERVER["HTTP_HOST"])); // if session exists, read user data if ($res) { $res = $res->fetch(); if (isset($res->person_id)) { $res = db_query("SELECT * FROM {cdb_person}\n WHERE id=:id", array(":id" => $res->person_id))->fetch(); $res->auth = getUserAuthorization($res->id); $_SESSION['user'] = $res; addInfoMessage(t('welcome.back.x', $res->vorname), true); } } } } if (!isset($_SESSION['user'])) { createAnonymousUser(); } } else { $_SESSION["user"]->auth = getUserAuthorization($_SESSION["user"]->id); if (isset($_COOKIE['CC_SessionId'])) { $dt = new DateTime(); db_query("UPDATE {cc_session} SET datum=:datum\n WHERE person_id=:p_id AND session=:session AND hostname=:hostname", array(":datum" => $dt->format('Y-m-d H:i:s'), ":session" => $_COOKIE['CC_SessionId'], ":p_id" => $_SESSION["user"]->id, ":hostname" => $_SERVER["HTTP_HOST"])); } } }