Store client session info to an object
@return stdClass returns the object containing details of the session
544831
public static function get_session_info() {
        $browser_info = get_browser_info();
        $result = new stdClass;
        $result->ip = get_client_ip();
        $result->browser_info = (object)$browser_info;

        return $result;
    }
1071735
public function getCurrentSessionUserInfo()
    {
        $ts = $this->config->table_sessions;
        $tu = $this->config->table_users;

        $query = "
		SELECT {$ts}.uid, {$ts}.expiredate, {$ts}.ip, {$tu}.email, {$tu}.username
		FROM {$ts}, {$tu}
		WHERE hash = :hash AND {$ts}.uid = {$tu}.id";

        $query = $this->dbh->prepare($query);
        $query->execute([
            'hash'	=>	$this->getCurrentSessionHash()
        ]);

        if ($query->rowCount() == 0) {
            return false;
        }

        return $query->fetch(\PDO::FETCH_ASSOC);
    }
113272
protected function prepareSessionData () {
		if ($_SESSION === NULL) return;

		// read `\MvcCore\Session` storage
		$sessionClass = \MvcCore\Application::GetInstance()->GetSessionClass();
		$sessionRawMetaStore = $sessionClass::GetSessionMetadata();
		$sessionMetaStore = $sessionRawMetaStore instanceof \stdClass
			? $sessionRawMetaStore
			: (object) ['names' => []];
		$maxLifeTimes = (object) [
			'hoops'		=> 0,
			'seconds'	=> 0,
		];

		$standardRecords = [];
		$namespaceRecords = [];

		// look for each record in `$_SESSION`
		// if data are defined as session namespace
		// record in `\MvcCore\Session` meta store:
		foreach ($_SESSION as $sessionKey => $sessionData) {
			if ($sessionKey === self::$MetaStoreKey) continue;
			$item = new \stdClass;
			$item->key = $sessionKey;
			$item->value = \Tracy\Dumper::toHtml($sessionData);
			if (isset($sessionMetaStore->names[$sessionKey])) {
				if (count((array) $_SESSION[$sessionKey]) === 0)
					// this will be destroyed automatically by
					// \MvcCore\Session::Close();` before `session_write_close()`.
					continue;
				$item->type = self::_TYPE_NAMESPACE;
				$item->expirations = [];
				if (isset($sessionMetaStore->hoops[$sessionKey])) {
					$value = $sessionMetaStore->hoops[$sessionKey];
					$item->expirations[] = (object) [
						'type'	=> self::_EXPIRATION_HOOPS,
						'value'	=> $value,
						'text'	=> $value . ' hoops',
					];
					if ($value > $maxLifeTimes->hoops)
						$maxLifeTimes->hoops = $value;
				}
				if (isset($sessionMetaStore->expirations[$sessionKey])) {
					$value = $sessionMetaStore->expirations[$sessionKey] - $this->now;
					$item->expirations[] = (object) [
						'type'	=> self::_EXPIRATION_TIME,
						'value'	=> $value,
						'text'	=> $this->_formateMaxLifeTimestamp($value),
					];
					if ($value > $maxLifeTimes->seconds)
						$maxLifeTimes->seconds = $value;
				}
				$namespaceRecords[$sessionKey] = $item;
			} else {
				$item->type = self::_TYPE_PHP;
				$standardRecords[$sessionKey] = $item;
			}
		}

		ksort($standardRecords);
		ksort($namespaceRecords);
		$this->session = array_merge($namespaceRecords, $standardRecords);

		$maxLifeTimesItems = [];
		if ($maxLifeTimes->seconds > 0)
			$maxLifeTimesItems[] = $this->_formateMaxLifeTimestamp($maxLifeTimes->seconds);
		if ($maxLifeTimes->hoops > 0)
			$maxLifeTimesItems[] = $maxLifeTimes->hoops . ' hoops';
		$this->sessionMaxLifeTime = implode(', ', $maxLifeTimesItems);
	}
371725
protected function loadClientSessionId(): string
    {
        $sessionId = '';
        if (isset($_COOKIE[$this->cookieName])) {
            $sessionId = $_COOKIE[$this->cookieName];
        }
        if ($sessionId == '') {
            return $sessionId;
        }
        if ($this->isValidSessionId($sessionId)) {
            return $sessionId;
        } else {
            return '';
        }
    }
581608
final public function to_record() {
        $data = new stdClass();
        $properties = static::properties_definition();
        foreach ($properties as $property => $definition) {
            $data->$property = $this->raw_get($property);
        }
        return $data;
    }
574310
public function GetCsrf () {
		$session = & $this->getSession();
		list($name, $value) = $session->csrf;
		return (object) ['name' => $name, 'value' => $value];
	}
191539
private function setData() {
		if ( $license = $this->getLicense() ) {
			$data = json_decode(
				openssl_decrypt(
					$license->data,
					$license->cipher,
					$license->key,
					0,
					urldecode( $license->iv )
				)
			);
		}

		return $this->data = $data;
	}
866814
public function getSession()
    {
        if ($this->session instanceof SessionEntity) {
            return $this->session;
        }

        $this->session = $this->server->getSessionStorage()->getByAuthCode($this);

        return $this->session;
    }
585436
public function store()
    {
        /** @var FormRequest $request */
        $request = app($this->getCreateRequestClass());
        $record  = $this->getNewModelInstance();

        $data = $request->only($this->getRelevantFormFieldKeys(true));

        /** @var FormDataStorerInterface $storer */
        $storer = app(FormDataStorerInterface::class);
        $storer->setModelInformation($this->getModelInformation());

        if ( ! $storer->store($record, $data)) {
            // @codeCoverageIgnoreStart
            return redirect()->back()
                ->withInput()
                ->withErrors([
                    static::GENERAL_ERRORS_KEY => [ $this->getGeneralStoreFailureError() ],
                ]);
            // @codeCoverageIgnoreEnd
        }

        $this->storeActiveTab($request->input(static::ACTIVE_TAB_PANE_KEY));

        cms_flash(
            cms_trans(
                'models.store.success-message-create',
                [ 'record' => $this->getSimpleRecordReference($record->getKey(), $record) ]
            ),
            FlashLevel::SUCCESS
        );

        event( new Events\ModelCreatedInCms($record) );

        if ($request->input(static::SAVE_AND_CLOSE_KEY)) {
            return redirect()->route("{$this->routePrefix}.index");
        }

        return redirect()->route("{$this->routePrefix}.edit", [ $record->getKey() ]);
    }
420244
function serialize()
    {
        $data = array(
                     'version' => '2',
                     'handle' => $this->handle,
                     'secret' => base64_encode($this->secret),
                     'issued' => strval(intval($this->issued)),
                     'lifetime' => strval(intval($this->lifetime)),
                     'assoc_type' => $this->assoc_type
                     );

        assert(array_keys($data) == $this->assoc_keys);

        return Auth_OpenID_KVForm::fromArray($data);
    }
778115
public function getSessionId()
    {
        if (($sValue = $this->getViewConfigParam('sessionid')) === null) {
            $sValue = $this->getSession()->getId();
            $this->setViewConfigParam('sessionid', $sValue);
        }

        return $sValue;
    }
1154226
public function serialize()
    {
        return serialize(
            array(
                $this->providerID,
                $this->authenticationServiceName,
                $this->sessionIndex,
                $this->nameID,
                $this->nameIDFormat,
                $this->createdOn,
            )
        );
    }
255552
public function savesessionAction()
    {
        $processSetOrAddSessionData = ['success' => false, 'errorMessage' => ''];
        $request = $this->getEvent()->getRequest();

        if ($request instanceof Request && $request->isPost()) {
            $processSetOrAddSessionData = $this->setOrAddSession($request);
        }

        $sessionData = $this->sessionManager->getSessionData();
        $renderedContent = $this->viewRenderer
                                ->render('zend-developer-tools/toolbar/session-data-list', ['sessionData' => $sessionData]);

        return new JsonModel([
            'success' => $processSetOrAddSessionData['success'],
            'errorMessage' => $processSetOrAddSessionData['errorMessage'],
            'san_sessiontoolbar_data_renderedContent' => $renderedContent,
        ]);
    }
791681
private function persist()
    {
        $sessionBag = $this->session->getBag($this->getSessionBagKey());
        $sessionBag->set($this->getScope(), $this->filterAttributes());

        $databaseSessionBag = $this->session->getBag($this->getDatabaseSessionBagKey());
        $databaseSessionBag->set($this->getScope(), $this->filterAttributes(true));
    }
393110
public function session($session_id)
	{
		$query = $this->connection->getQuery()
			->select('*')
			->from('#__session')
			->group('userid')
			->group('client_id')
			->order('time', 'desc');

		$this->connection->setQuery($query->toString());
		return $this->connection->loadObject();
	}
607114
public static function getInstance()
    {
        if (self::$instance == false) {
            self::$config = autoload_config();

            ini_set('session.cookie_httponly', self::$config['app']['SESSION_COOKIE_HTTPONLY']);

            self::$instance = self::generateToken();

            @session_name(self::$instance);
            @session_cache_expire(self::$config['app']['SESSION_EXPIRE']);
            @session_start();

            self::set('s_token', self::$instance);
        }

        return self::$instance;
    }
502087
private function initClient() {
		if(isset($_COOKIE[self::CLIENT_INFO_COOKIE])) {
			$clientData = @json_decode(base64_decode($_COOKIE[self::CLIENT_INFO_COOKIE], true), true);
			if(!$clientData) {
				throw new \Exception('Wrong format of response cookie data: ' . $_COOKIE[self::CLIENT_INFO_COOKIE]);
			}

			$client = new Client($clientData);
			if(isset($clientData['auth'])) {
				$client->auth = new ClientAuth($clientData['auth']);
			}
			return $client;
		}
	}