function testSave() { AbstractSession::destroySafely(); call_user_func($this->handler . '::init', $this->wrapper); $_SESSION['foo'] = 'bar'; $id = session_id(); session_write_close(); $sessFetched = $this->wrapper->get($this->prefix . $id); $this->assertNotEmpty($sessFetched, _unit_dump(['id' => $id, 'fetched' => $sessFetched, 'all' => $this->wrapper->getAll(), 'is_available' => $this->wrapper->isAvailable()])); $this->assertTrue(stripos($sessFetched, 'foo') !== false, '"foo" not found in session data'); $this->assertTrue(stripos($sessFetched, 'bar') !== false, '"bar" not found in session data'); }
/** * Sets a profiler mark * * @author Art <*****@*****.**> * * @param string $identifier How to identify this mark * * @return Profiler */ function mark($identifier) { $m =& $this->marks[$identifier]; $r =& \Alo::$router; $m = [self::P_MICROTIME => microtime(true), self::P_SESSION_DATA => AbstractSession::isActive() ? $_SESSION : false, self::P_GET => $_GET, self::P_POST => $_POST, self::P_FILES => $_FILES, self::P_CONTROLLER => $r->getController(), self::P_CONTROLLER_METHOD => $r->getMethod(), self::P_PORT => $r->getPort(), self::P_REMOTE_ADDR => $r->getRemoteAddr(), self::P_REQUEST_METHOD => $r->getRequestMethod(), self::P_REQUEST_SCHEME => $r->getRequestScheme(), self::P_SERVER_ADDR => $r->getServerAddr(), self::P_SERVER_NAME => $r->getServerName(), self::P_HEADERS => \getallheaders(), self::P_REQUEST_PATH => $r->getPath(), self::P_MEMORY_USAGE => memory_get_usage(false), self::P_REAL_MEMORY_USAGE => memory_get_usage(true)]; return $this; }
/** * Destroys a session * * @author Art <*****@*****.**> * * @param string $sessionID The ID to destroy * * @return bool */ public function destroy($sessionID) { parent::destroy($sessionID); return $this->client->delete($this->prefix . $sessionID); }
/** * Initialises a MySQLSession * @author Art <*****@*****.**> * * @param MySQL $dependcyObject If you don't want to use Alo::$db you can pass a MySQL instance reference here. */ static function init(MySQL &$dependcyObject = null) { parent::initSession($dependcyObject, get_class()); }
/** * Removes a token from session data * * @author Art <*****@*****.**> * * @param string $tokenName The token's name * * @return bool TRUE if the session handler was loaded, false if not */ static function tokenRemove($tokenName) { if (AbstractSession::isActive()) { unset($_SESSION[$tokenName]); return true; } else { phpWarning('Session not initialised - tokens unavailable.'); return false; } }