Home >Backend Development >PHP Tutorial >Issues with identity verification through session_id

Issues with identity verification through session_id

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-06 13:53:061129browse

php code

<code>账号密码验证成功:
                session('uid',100);
                $sid=session_id();
                $this->ajaxReturn(array("result"=>"1","sessionid"=>$sid));
               </code>

The html page will save the session_id in a cookie named sid

<code>  $.cookie('sid', response.data.sessionid);</code>

Verify php, sid (session_id) will be sent for each page request

<code>      $sid=I('post.sid');

        session_id($sid);

        $this->ajaxReturn(array("uid"=>session('uid'),"sid"=>"$sid"));
</code>

Problem: The value of the session cannot be obtained. The value obtained is still null
But the sid is passed normally

Reply content:

php code

<code>账号密码验证成功:
                session('uid',100);
                $sid=session_id();
                $this->ajaxReturn(array("result"=>"1","sessionid"=>$sid));
               </code>

The html page will save the session_id in a cookie named sid

<code>  $.cookie('sid', response.data.sessionid);</code>

Verify php, sid (session_id) will be sent for each page request

<code>      $sid=I('post.sid');

        session_id($sid);

        $this->ajaxReturn(array("uid"=>session('uid'),"sid"=>"$sid"));
</code>

Problem: The value of the session cannot be obtained. The value obtained is still null
But the sid is passed normally

The session will automatically save the session ID on the client, and each request will also carry the session ID to the server. No additional processing is required. I don't know what the purpose of defining an additional sid cookie is.
In addition, cookies are scope-specific. Are the domains you requested the same twice?

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
Previous article:nginx access deniedNext article:nginx access denied