/** * Check if the current user is logged in * * @return boolean|integer */ public function isLoggedIn() { if ($this->_isLoggedIn !== null) { return $this->_isLoggedIn; } if (!isset($_SESSION['ZOODSID']) || !$_SESSION['ZOODSID']) { return $this->_isLoggedIn = false; } else { require_once ZOODPP_APP . '/models/SessionModel.php'; $sessionid = $_SESSION['ZOODSID']; $session = SessionModel::getSessionBySessionid($sessionid); if ($session) { $this->_isLoggedIn = $session['userid']; $this->_userid = $session['userid']; $this->_username = $session['username']; } else { $this->_isLoggedIn = false; } return $this->_isLoggedIn; } }
/** * Logout * * @return unknown_type */ public function logoutAction() { require_once ZOODPP_APP . '/models/SessionModel.php'; $sessionid = isset($_SESSION['ZOODSID']) ? $_SESSION['ZOODSID'] : (isset($_COOKIE['ZOODSID']) ? $_COOKIE['ZOODSID'] : session_id()); $csession = SessionModel::getSessionBySessionid($sessionid); if ($csession) { SessionModel::deleteSession($sessionid); } $_SESSION['ZOODSID'] = null; setcookie('ZOODSID', null, time() - 3600000000.0, '/'); echo "Logout successfully!"; }