I have been using $_SESSION forever and never had an issue. Tonight things are not working when I'm trying to build a new app using the same session logic. I've been trying to debug this for hours looking online to no avail. The session.php keeps redirecting me to the login page. I feel stupid.
login.php
session_start();
$_SESSION['user_id'] = 'superUser';
header("Location: dashboard.php");
exit();
session.php
<?php
session_start();
if ( isset( $_SESSION['user_id'] ) ) {
// do something here
} else {
// Redirect them to the login page
header("Location: login.php");
exit();
}
?>
dahsboard.php
<?php
include_once 'session.php';
echo 'dashboard';