Why does the session_id of the page requested by curl keep changing?

WBOY
Release: 2016-08-04 09:19:31
Original
1576 people have browsed it

Why does the session_id of the page requested by curl keep changing?
If: a.php uses curl to request b.php, then the session_id of b.php keeps changing. Why is this?
If a.php and b.php are in different domains, the session_id cannot always be understood. My a.php and b.php are in the same directory. Why is this?
For safety reasons

Reply content:

Why does the session_id of the page requested by curl keep changing?
If: a.php uses curl to request b.php, then the session_id of b.php keeps changing. Why is this?
If a.php and b.php are in different domains, the session_id cannot always be understood. My a.php and b.php are in the same directory. Why is this?
For safety reasons

Session is generated by the first request and placed in the cookie. If you do not pass it to the server, the server will think you are a new user and generate a new session id for you.

If you think about it carefully,
curl will definitely not bring things like cookies to the server unless specified. So...

The sessionID is stored in the cookie, and this cookie will be brought along every time the client sends a request (the stateless nature of HTTP).
When curl requests b.php for the first time, you need to capture the cookie and save it locally. You can open this cookie to see the content inside.
When you access b.php through curl for the second time, bring the previously saved cookies.

Yes, you need to bring cookies. This is the principle of simulated login.

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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template