set item to session
public setSession ( string $key = null, mixed $value = null ) | ||
$key | string | key of the item |
$value | mixed | value of the item |
/** * log * * @since 2.2.0 * * @return array */ protected static function _log() { $root = Registry::get('root'); $fullRoute = Registry::get('fullRoute'); $recentView = Request::getSession($root . '/recent_view'); /* handle recent view */ if ($fullRoute && current($recentView) !== $fullRoute) { if (!is_array($recentView)) { $recentView = array(); } array_unshift($recentView, $fullRoute); Request::setSession($root . '/recent_view', $recentView); } $output = $recentView; return $output; }
/** * detect the required asset * * @since 2.0.0 * * @param array $setup array of detector setup * @param string $type type of the asset * @param string $path path to the required file */ protected function _detect($setup = array(), $type = null, $path = null) { foreach ($setup as $key => $value) { if (isset($value)) { $file = str_replace('{value}', $value, $path); /* if file exists */ if (file_exists($file)) { $this->_output = $value; /* store query to session */ if ($key === 'query') { $root = $this->_registry->get('root'); Request::setSession($root . '/' . $type, $value); } break; } } } }
/** * login * * @since 2.2.0 */ protected static function _login() { $root = Registry::get('root'); $token = Registry::get('token'); /* session values */ Request::setSession($root . '/logged_in', $token); Request::setSession($root . '/my_name', 'Anonymous'); Request::setSession($root . '/my_user', 'demo'); Request::setSession($root . '/my_email', '*****@*****.**'); Request::setSession($root . '/categories_new', 1); Request::setSession($root . '/categories_edit', 1); Request::setSession($root . '/articles_new', 1); Request::setSession($root . '/articles_edit', 1); Request::setSession($root . '/comments_new', 1); Request::setSession($root . '/comments_edit', 1); Request::setSession($root . '/settings_edit', 1); Request::setSession($root . '/filter', 1); /* notification */ notification(l('welcome'), l('logged_in'), l('continue'), 'admin'); }
/** * login * * @since 2.4.0 */ protected static function _login() { $root = Registry::get('root'); $token = Registry::get('token'); $tableArray = array('categories', 'articles', 'extras', 'comments', 'groups', 'users'); /* session values */ Request::setSession($root . '/logged_in', $token); Request::setSession($root . '/my_name', 'Demo'); Request::setSession($root . '/my_user', 'demo'); Request::setSession($root . '/my_email', 'demo@localhost'); foreach ($tableArray as $value) { Request::setSession($root . '/' . $value . '_new', 1); Request::setSession($root . '/' . $value . '_edit', 1); Request::setSession($root . '/' . $value . '_delete', 1); } Request::setSession($root . '/modules_install', 0); Request::setSession($root . '/modules_edit', 0); Request::setSession($root . '/modules_uninstall', 0); Request::setSession($root . '/settings_edit', 1); Request::setSession($root . '/filter', 1); /* notification */ notification(Language::get('welcome'), Language::get('logged_in'), Language::get('continue'), 'admin'); }
/** * testSession * * @since 2.2.0 */ public function testSession() { /* setup */ Request::setSession('testKey', 'testValue'); /* result */ $result = Request::getSession('testKey'); /* compare */ $this->assertEquals('testValue', $result); }