Пример #1
0
 public static function restore_roles()
 {
     $role_configs = self::$configs['roles'];
     $is_guest = true;
     foreach ($role_configs as $role_name => $role_config) {
         $role_sid = self::c_str($role_config['sid_name'], '');
         if ($role_sid === '') {
             $session_record = ['sid' => null, 'session' => null];
         } else {
             $session = session_manager::fetch_session($role_name, $role_sid);
             if ($session !== null) {
                 $is_guest = false;
             }
             $session_record = ['sid' => $role_sid, 'session' => $session];
         }
         self::$session_records[$role_name] = $session_record;
     }
     self::$is_guest = $is_guest;
 }
Пример #2
0
<?php

/**
 * 会话及其管理器
 *
 * @copyright Copyright (c) 2009-2015 Jingcheng Zhang <*****@*****.**>. All rights reserved.
 * @license   See "LICENSE" file bundled with this distribution.
 */
namespace kern;

session_manager::__init__();
// [类型] 会话
class session
{
    public function has($key)
    {
        return array_key_exists($key, $this->role_vars);
    }
    public function get($key, $default_value = null)
    {
        return $this->has($key) ? $this->role_vars[$key] : $default_value;
    }
    public function get_all()
    {
        return $this->role_vars;
    }
    public function set($key, $value)
    {
        $this->role_vars[$key] = $value;
        $this->needs_update = true;
    }