Home >Backend Development >PHP Tutorial >大神在吗?PHP关于session跟cookie的修改看不懂啊

大神在吗?PHP关于session跟cookie的修改看不懂啊

WBOY
WBOYOriginal
2016-06-13 11:54:07762browse

大神在吗?PHP关于session和cookie的修改看不懂啊!
帮忙看下下面两个功能是否修改了SESSIONID,为什么我始终获取不到正确的id呢?每次浏览器生成的都是固定的id,而我获取到的id都是在变化的。

/**<br> * session管理函数<br> * @param string|array $name session名称 如果为数组则表示进行session设置<br> * @param mixed $value session值<br> * @return mixed<br> */<br>function session($name,$value='') {<br>    $prefix   =  C('SESSION_PREFIX');<br>    if(is_array($name)) { // session初始化 在session_start 之前调用<br>        if(isset($name['prefix'])) C('SESSION_PREFIX',$name['prefix']);<br>        if(C('VAR_SESSION_ID') && isset($_REQUEST[C('VAR_SESSION_ID')])){<br>            session_id($_REQUEST[C('VAR_SESSION_ID')]);<br>        }elseif(isset($name['id'])) {<br>            session_id($name['id']);<br>        }<br>        ini_set('session.auto_start', 0);<br>        if(isset($name['name']))            session_name($name['name']);<br>        if(isset($name['path']))            session_save_path($name['path']);<br>        if(isset($name['domain']))          ini_set('session.cookie_domain', $name['domain']);<br>        if(isset($name['expire']))          ini_set('session.gc_maxlifetime', $name['expire']);<br>        if(isset($name['use_trans_sid']))   ini_set('session.use_trans_sid', $name['use_trans_sid']?1:0);<br>        if(isset($name['use_cookies']))     ini_set('session.use_cookies', $name['use_cookies']?1:0);<br>        if(isset($name['cache_limiter']))   session_cache_limiter($name['cache_limiter']);<br>        if(isset($name['cache_expire']))    session_cache_expire($name['cache_expire']);<br>        if(isset($name['type']))            C('SESSION_TYPE',$name['type']);<br>        if(C('SESSION_TYPE')) { // 读取session驱动<br>            $class      = 'Session'. ucwords(strtolower(C('SESSION_TYPE')));<br>            // 检查驱动类<br>            if(require_cache(EXTEND_PATH.'Driver/Session/'.$class.'.class.php')) {<br>                $hander = new $class();<br>                $hander->execute();<br>            }else {<br>                // 类没有定义<br>                throw_exception(L('_CLASS_NOT_EXIST_').': ' . $class);<br>            }<br>        }<br>        // 启动session<br>        if(C('SESSION_AUTO_START'))  session_start();<br>    }elseif('' === $value){ <br>        if(0===strpos($name,'[')) { // session 操作<br>            if('[pause]'==$name){ // 暂停session<br>                session_write_close();<br>            }elseif('[start]'==$name){ // 启动session<br>                session_start();<br>            }elseif('[destroy]'==$name){ // 销毁session<br>                $_SESSION =  array();<br>                session_unset();<br>                session_destroy();<br>            }elseif('[regenerate]'==$name){ // 重新生成id<br>                session_regenerate_id();<br>            }<br>        }elseif(0===strpos($name,'?')){ // 检查session<br>            $name   =  substr($name,1);<div class="clear">
                 
              
              
        
            </div>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn