Reputation: 43
I have a log-in, a registration and a reservation page. When people registrate, then log-in and then make a reservation, I want to get the userId (which is the name for the Id in my mysql database) from the logged-in person. I've been told that it's like this:
$_SESSION["userId"]
When I do this it gives me an error saying undefined index: userId Someone told me to put the userId in the Session, but i have no idea how because I'm still a beginner. I've tried to google it but with no success.
var_dump["$_SESSION"]
Gives me:
Registration page = array(0) { }
Log-in page = array(0) { }
reservation page = array(1) { ["loggedIn"]=> bool(true) }
Upvotes: 1
Views: 9649
Reputation: 777
Just put your code as $_SESSION["userId"] = $userID;
where $userID is the data getting from post or get method
Upvotes: 1