The use of $_SESSION is much preferred, as of PHP 4.1.0, eg:
$_SESSION["test"] = "Hello there";
And very importantly, use session_start() to create a session or resume the current one based on the current session id that's being passed via a request, such as GET, POST, or a cookie.
Ja thanx Dennis, had some trouble with the session stuff. Got it working in the end. Feels like a mechanic trying to fix a broken machine with an old manual.
I typed the code as in the assignment (I do not understand what Dennis is talking about):
I get this:
Warning: open(/tmp\sess_3249d9895fed3ac7557a2e14f659d3e9, O_RDWR) failed: No such file or directory (2) in C:\FoxServ\www\StudentPHP\session.php on line 4
Then I get the HTML bit with the buttons, etc.
Beneath this I get:
Warning: open(/tmp\sess_3249d9895fed3ac7557a2e14f659d3e9, O_RDWR) failed: No such file or directory (2) in C:\FoxServ\www\StudentPHP\session.php on line 4
I can change colors, but if I click on the [Refresh, do not change colors] link, the colors revert to white.
[Go to other page] link displays:
Warning: open(/tmp\sess_942de149d10b26c4f8b4cdbae8389f9d, O_RDWR) failed: No such file or directory (2) in C:\FoxServ\www\StudentPHP\session2.php on line 5
and
Warning: open(/tmp\sess_942de149d10b26c4f8b4cdbae8389f9d, O_RDWR) failed: No such file or directory (2) in Unknown on line 0
Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0