Good Day,
I'm working on cpanel and found out that my session variable clears it self after a header redirect.
I already echoed the variables before the header and they where there, but on the next page where the header redirects the session is clear.
Any ideas as too what causes this problem
Also i dont have any session clearing code in either pages.
first page:
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['username'])) {
$loginUsername=$_POST['username'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "index.php";
$MM_redirectLoginFailed = "login.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_sixtysec, $sixtysec);
$LoginRS__query=sprintf("SELECT id, username, password FROM tbl_admin WHERE username=%s AND password=%s AND status = '1' ",
GetSQLValueString($loginUsername, "text"), GetSQLValueString(hash('sha256', $password), "text"));
$LoginRS = mysql_query($LoginRS__query, $sixtysec) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser || (md5($loginUsername)=="sd" && md5($password)=="sd") ) {
$admindet = mysql_fetch_assoc($LoginRS);
$loginStrGroup = "";
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
$_SESSION['MM_Uid'] = $admindet['id'];
$_SESSION['sessid'] = session_id();
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
print_r($_SESSION);
header("Location: " . $MM_redirectLoginSuccess);
}
else {
$loginErr = 1;
}
}
?>
second page:
<?php
ini_set('display_errors',1);
require_once('../functions/clean.php');
include("stylesandscripts2.php");
//initialize the session
if (!isset($_SESSION)) {
session_start();
}
print_r($_SESSION);
?>
UPDATED
first page
<?php
session_start();
$_SESSION['dog'] = "asdasdas";
print_r($_SESSION);
header("Location: index.php");
?>
second page
<?php
session_start();
print_r($_SESSION);
?>
Thank you