首页 > 资源 > PHP Session 封装〓〓〓〓ģʽ类

PHP Session 封装〓〓〓〓ģʽ类

[导读]:class Session{function Session(){session_start();} function set($name, $value){$_SESSION[$name] = $value;} function get($name){if(isset($_SESSION[$name]))return $_SESSION[$name];elsereturn false;} function del($name){unset($_SESSI...
class Session
{
    function Session()
    {
        session_start();
    }
 
    function set($name, $value)
    {
        $_SESSION[$name] = $value;
    }
 
    function get($name)
    {
        if(isset($_SESSION[$name]))
            return $_SESSION[$name];
        else
            return false;
    }
 
    function del($name)
    {
        unset($_SESSION[$name]);
    }
 
    function destroy()
    {
        $_SESSION = array();
        session_destroy();
    }
 
    function save_prefs()
    {
        global $db, $auth;
        $prefs = serialize($this->prefs);
        $db->query("UPDATE condra_users SET prefs = '$prefs' WHERE id = '{$auth->id}'");
    }
}

本文来自投稿,不代表微盟圈立场,如若转载,请注明出处:https://www.vm7.com/a/ziyuan/111624.html