PHP session variable not carried through pages

Website URL

Session Not persist through pages

This is the login page… i started the seesion_start() function and stored a var 0 in $_session[‘admin’]. and header to the home page…

session_start();
$_SESSION['admin'] = 0;
error_reporting(1);
include('../config/config.php');

$data="SELECT * FROM `admin`";
$result = $mysqli -> query($data);
$row = $result  -> fetch_array(MYSQLI_ASSOC);
$adminName =  $row['Name'];
$password = $row['Password'];

$mes = "Session id: ".session_start();

$name = $_POST['name'];
$pass = $_POST['password'];

if(isset($_POST['btn'])){
if($adminName == $name && $password == $pass){
  $_SESSION['admin'] = 1;

  $mes = 'GOOD'.$_SESSION['admin'];
  header("location:https://vinnovista.rf.gd/admin/home.php");
  

}else {
   $mes = 'Password/Username Incorrect ';
}
}

on the home page …the $_session[‘admin’] is just null…Why??
As you can see below the page would just load ‘nope’…


session_start(); // Start the session


error_reporting(1);
if($_SESSION['admin']){
    echo 'yes there is';
}else{
    echo 'nope';
    
}
if($_SESSION['admin']!=1){
    // header('location:index.php');
    echo "not 1";
    phpinfo();
    echo $_SESSION['admin'];
}else{
?>

I would appreciate any feedback please…

same for me

Two servers just completed an upgrade from PHP 7.4 to PHP 8.2, so sessions may be broken (I cannot verify this). If this is so, please have patience, as I’m sure iFastNet is working to resolve this issue.

8 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.