I'm working with a login.php page. when users login successfully, system will save their usernames into session.like below code:
if ($user != null) {
$_SESSION['username'] = $user["username"];
$_SESSION['userid'] = $user["id"];
return 0;
}
Then the page will be located to main.php. Main.php will read the session, like below code:
session_start();
if (isset($_SESSION['username']) == false || empty($_SESSION['username']))
{
// transfer into login page
}
else
{
echo $_SESSION['username'];
}
The main page can't read the $_SESSION['username'], the value is null. What should I do now?