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
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.