I would like to know if it is possible to read $_SESSION attributes without locking it.
Currently, session_start()
locks SESSION, that means other PHP proce
Personally I do this right at the start:
session_start();
session_write_close();
And then you have access to $_SESSION as read-only. As you can see below, you do not need to copy the session variables.
session_start();
//This value will be "The #1 Value!" only the 2nd time you run this
echo "
myData value1:".$_SESSION['myData'];
$_SESSION['myData'] = "Value 2 and 3!";
session_write_close();
echo "
myData value2 (read-only):".$_SESSION['myData'];
$_SESSION['myData'] = "Value 3 Misleading, and never actually written to the session!";
//But it will affect this value, obviously
echo "
myData value3:".$_SESSION['myData'];
session_start();
//NOTE HOW THE ABOVE LINE WRITES-OVER $_SESSION
echo "
myData value4:".$_SESSION['myData'];
$_SESSION['myData'] = "The #1 Value!";
session_write_close();