After hours of trying to sort out my problem I am thinking that it is perhaps not my coding but some setting that needs attention. But being quite new to PHP I have no idea what it might be.
I have been working on some code requiring sessions. I have set the sessions on each page of coding as I understand is required but the information is not being passed from one page to the other.
So I went back and tested a simple exercise that I did at college which I know worked on the college computer and found the same problem.
The exercise that is not working is:
<?php
session_start();
$username = $SESSION['username'];
$userid = $SESSION['userid'];
echo "<h1>Your session ID is ".session_id()."</h1>";
echo "<h2>The Session variable called username has a value of $username</h2>";
echo "<h2>The Session variable called userid has a value of $userid</h2>";
?>
I get the following result:
Notice: Undefined index: username in C:\xampp\htdocs\sss11_eg1b.php on line 3
Notice: Undefined index: userid in C:\xampp\htdocs\sss11_eg1b.php on line 4
Your session ID is lehd6n7ku6o4g8op1tclrl4uv3
The Session variable called username has a value of
The Session variable called userid has a value of
This is exactly what is happening with the code I have been working on.
Please can anyone point me in the direction of what the problem might be and if it is some sort of setting could you spell it out in simple language as I am quite inexperienced with that sort of thing.
Thank you