/** * * @return \Application\Models\User */ public static function getCurrentLogged() { $user = null; $username = Filter::html_entity_invert(\Application\Services\Session::get(\Application\Services\Session::SESSION_USER_NAME)); if ($username !== null) { $user = self::getByUsername($username); } return $user; }
/** * * A tutte le stringhe salvate in sessione applico il filtro Filter::MyXSSFilter() * Quindi per visualizzarle correttamente devo decodificarle con questo metodo * * @param unknown $key * @return string */ public static function getDecoded($key) { return Filter::html_entity_invert(Session::get($key)); }
/** * Deletes the cookie * It's necessary to split deleteCookie() and logout() as cookies are deleted without logging out too! * Sets the remember-me-cookie to ten years ago (3600sec * 24 hours * 365 days * 10). * that's obviously the best practice to kill a cookie @see http://stackoverflow.com/a/686166/1114320 */ public static function deleteCookie($user_name = null) { // is $user_name was set, then clear remember_me token in database if ($user_name) { $user_name = Filter::html_entity_invert($user_name); $user = UserModel::getByUsername($user_name); $user->setRemembermetoken(NULL); $em = DbResource::getEntityManager(); $em->persist($user); $em->flush(); } // delete remember_me cookie in browser setcookie(self::COOKIE_REMEMBER_ME, false, time() - 3600 * 24 * 3650, Config::get('cookie.path'), Config::get('cookie.domain'), Config::get('cookie.secure'), Config::get('cookie.http')); }