I have a hosting account that can host only one domain. However, I created a sub folder and forwarded another domain to that folder which contains an index.php file.
This worked fine until I decided to add a login mechanism. I executed login script and forwarded the user to another sub folder.
This is my login code
$userPwd = $_POST['pwd'];
$userName = $_POST['un'];
$dbPwd;
$dbPwd=$dbCls->db->query("SELECT Password FROM users WHERE TRIM(UserName)='" .$userName ."';")->fetch_assoc()['Password'];
if(strcmp(hash("sha256",$userPwd .salt()),$dbPwd)==0){
//Hash match
$_SESSION['UserId']=$dbCls->db->query("SELECT UserID FROM malinduusers WHERE TRIM(UserName)='" .$userName ."';")->fetch_assoc()['UserID'];
$_SESSION['UserName']=$userName;
header("Location:../Dashboard/");
}
But the problem is, when I forward to the subfolder, the $_SESSION variable is always empty, through I started the session with session_start();.
array(0){}
This is not a problem for the main hosted domain. For that, the $_SESSION is not reset and working fine.