php session

2019-10-24  本文已影响0人  AGEGG
//处理session存取的模式
session.save_handler = files
//session档案存放路径
session.save_path = /tmp
//session使用cookie的功能,启动: 1
session.use_cookies = 1
//session名字
session.name = PHPSESSID
//自动启动;0:关;1:开启
session.auto_start = 0
//session使用cookie的生存期,以秒为单位
session.cookie_lifetime = 0
    public static $session_start_flag = false;
    public static function session_start()
    {
        if (self::$session_start_flag == false) {
            session_start();
            $lifeTime = 10 * 3600;
            setcookie(session_name(), session_id(), time() + $lifeTime, "/");

            self::$session_start_flag = true;
        }
    }

    //设置session
    public function setSession($phone)
    {
        session_id(md5('wx'.$phone));
        self::session_start();
        $_SESSION["validate"] = 123;
    }

    //获取session
    public function getSession($phone)
    {
        session_id(md5('wx'.$phone));
        self::session_start();
        var_dump($_SESSION);
    }
上一篇下一篇

猜你喜欢

热点阅读