PHP sessions are cookie-based (generally, if the client does not support cookies, the url query method is used).
PHP creation session code:
<?php
session_start();
$_SESSION['name'] = 'value';
?>Accessing this file with a browser will generate a Set-Cookie http response header, and a cookie named “PHPSESSID” is set on the client.
Open F12’s “Apps” and check the existing cookies, then you will see the cookies that have just been set.
Refresh this PHP file again.
You can see that there is no Set-Cookie header in the response header.
At this time, PHPSESSID’s cookie already exists in the cookie.
The existing PHPSESSID cookie will be used in the future.
That is, the session will create a PHPSESSID cookie when the user first visits the page, and will not create this cookie thereafter until the session expires (usually 20 minutes) or the PHPSESSID cookie is deleted.

Leave a Reply