/** * Change current Session Handler * * @param string|Next\Session\Handlers\Handler $handler * Handler Object or Handler Name * * @throws Next\Session\Handlers\HandlerException * Changing Session Handler to a invalid Handler, characterized as * instance of Next\Session\Hndlers\Handler */ public function changeHandler($handler) { // If we don't have a true Handler... if (!$handler instanceof Handler) { // ... let's find an assigned Handler that matches given string $test = $this->handlers->find($handler); // Nothing Found? if (!$test instanceof Handler) { throw HandlersException::unknownHandler((string) $handler); } // Yeah! We're ninjas! $handler = $test; } // Committing Session $this->session->commit(); // Setting Session Options with Handler Options if (isset($handler->getOptions->savePath)) { $this->session->setSessionSavePath($handler->getOptions->savePath); } $lifetime = isset($handler->getOptions->lifetime) ? $handler->getOptions->lifetime : 0; if ($lifetime > 0) { $this->session->setSessionLifetime($lifetime); } // Changing current Session Handler $this->handler =& $handler; // Restarting Session $this->session->init($this->session->getSessionName(), $this->session->getSessionID()); }
public function signOut() { $s = new Session($this->getCookieValue()); if ($s->getId() && !$s->expired()) { $s->setLoggedOut(); $s->commit(); $this->clearCookie(); self::$instance = null; } }
/** * @return void * @Description Sitenin çalışabilmesi için gerekli bileşenlerin load edildiği method */ public static final function setPage() { // session bilgilerini set eder Session::set(); $LANGUAGE = new \model\language\Language($_GET); $LANGUAGE->init(); // login bilgilerini set eder //$AUTH = Auth::getInstance(); //$AUTH->init(); // formlar için token oluşturur Token::createTokenSession(); // ################################################################ parent::init(); // formMessage bilgisini siliyoruz Session::deleteSession(['formMessage']); // session commit Session::commit(); }
<?php namespace Tbmt; define('BASE_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR); try { require BASE_DIR . 'include' . DIRECTORY_SEPARATOR . 'bootstrap.php'; Session::start(); /* Dispatch controller ---------------------------------------------*/ list($controllerName, $controllerAction) = Arr::initList($_REQUEST, [Router::KEY_MODULE => [\Tbmt\TYPE_STRING, 'projects'], Router::KEY_ACTION => [\Tbmt\TYPE_STRING, 'index']]); define('CURRENT_MODULE', $controllerName); define('CURRENT_MODULE_ACTION', $controllerAction); $actionResult = ControllerDispatcher::dispatchAction($controllerName, $controllerAction); Session::commit(); if ($actionResult instanceof ControllerActionResult) { $actionResult->execute(); } else { echo (new view\Index())->render(['basePath' => '', 'windowtitle' => 'TostiMiltype', 'controllerBody' => $actionResult]); } } catch (PublicException $e) { echo view\PublicError::fromPublicException($e); } catch (\Exception $e) { error_log($e->__toString()); echo view\Error::fromException($e); }
public function finish() { Session::commit(); exit; }
<?php require __DIR__ . '/../src/autoload.php'; class Session extends spriebsch\session\AbstractSession { public function getCounter() { return $this->get('counter'); } public function incrementCounter() { if (!$this->has('counter')) { $this->set('counter', 0); } $this->set('counter', $this->get('counter') + 1); } } $session = new Session(new spriebsch\session\PhpSessionBackend()); $session->configure('session-name', 'localhost'); $session->start('foo'); $session->incrementCounter(); var_dump($session->getCounter()); $session->commit();