I have built a php backend library, for a ios app of mine, and I am using sessions to know if the user is logged in. But for some reason, even after setting the session variable, when I try to retrieve it, it is retrieved as undefined, making my app think the user isn't logged in, even though the user is logged in. Is there any alternative for using sessions, or did I setup my session wrong? Here is the code:
Login call:
session_start();
// Login stuff
$_SESSION["id"] = /* My id, which isn't undefined */;
Checking whether user is logged in or not:
session_start();
if (isset($_SESSION["id"])) {
$id = isset($_SESSION["id"]);
echo $id;
// do stuff
}
else {
echo "You are not logged in.";
// user not logged in
// This condition is always called, and I am not able to change it no matter what I do.
}