Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once(Path::sessionClassPath() . "Session.php");
- class SessionHandler {
- private $session;
- public function __construct() {
- if(isset($_SESSION["session"])) {
- $this->session = $this->retrieveSession();
- $this->refreshSessionSettings();
- }
- else {
- $this->session = new Session(null, null, null, null, null);
- }
- }
- /**
- * Creates a new Session object
- * @param int $sessionId
- * @param int $userId
- * @param String $username
- * @param int $authLevel
- * @param String $timezone
- */
- public function createSession($sessionId, $userId, $username, $authLevel, $timezone) {
- $this->session = new Session($sessionId, $userId, $username, $authLevel, $timezone);
- }
- public function updateSession($sessionId, $userId, $username, $authLevel, $timezone) {
- $this->createSession($sessionId, $userId, $username, $authLevel, $timezone);
- }
- /**
- * Query the user's timezone and authorization level from the database to update the session
- */
- private function refreshSessionSettings() {
- }
- /**
- * Kills the existing session.
- */
- public function destroySession() {
- $_SESSION = array();
- session_destroy();
- }
- /**
- * Saves the Session object to the $_SESSION[] storage.
- */
- public function saveSession() {
- unset($_SESSION["session"]);
- $_SESSION["session"] = serialize($this->session);
- }
- /**
- * Returns the Session object from the $_SESSION[] storage.
- * @return <b>Session</b> - Session object
- */
- private function retrieveSession() {
- return unserialize($_SESSION["session"]);
- }
- /**
- *
- * @return <b>int</b> - Session ID.
- */
- public function getSessionId() {
- return $this->session->getSessionId();
- }
- /**
- *
- * @return <b>int</b> - User ID.
- */
- public function getUserId() {
- return $this->session->getUserId();
- }
- /**
- *
- * @return <b>String</b> - Username.
- */
- public function getUsername() {
- return $this->session->getUsername();
- }
- /**
- *
- * @return <b>int</b> - Authorization level.
- */
- public function getAuthLevel() {
- return $this->session->getAuthLevel();
- }
- /**
- *
- * @return <b>String</b> - Timezone.
- */
- public function getTimezone() {
- return $this->session->getTimezone();
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment