So, I tried to verify this by doing the following.
test_1.php
session_start(); $_SESSION['my_variable']=1; sleep(20); exit;
and
test_2.php
session_start(); var_dump($_SESSION);
Here are the cases I tested:
- Run
test_1.php , then quickly run test_2.php .
Result: test_2.php freeze until test_1.php finishes sleeping.
- Executing
test_1.php , removing the cookie PHPSESSID and THEN executing test_2.php .
Result: test_2.php runs immediately without freezing ( test_1.php was still asleep) and printed an empty array.
Beginner Output:
PHP opens the stream to a text file associated with this session until the script completes execution and then "makes" the changes. (I am not an expert, so my conditions may not be accurate)
Edit: another useless test due to lack of documentation consultation
but since the session data is locked, to prevent only one script from being written at a time, it can work in the session at any time
source share