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

Issues with identity verification through session_id

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-06 13:53:06
Original
1130 people have browsed it

php code

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

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

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

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>
Copy after login
Copy after login

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>
Copy after login
Copy after login

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

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

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>
Copy after login
Copy after login

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?

Related labels:
source:php.cn
Statement of this Website
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
Latest Issues
Session
From 1970-01-01 08:00:00
0
0
0
session
From 1970-01-01 08:00:00
0
0
0
session login information
From 1970-01-01 08:00:00
0
0
0
session problem
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template