I have the following class which handles my user logged in / logged out (I only included what's relevant here). I want to redirect users who are logged in who visit login.php to there account page. I do this using....
$User = new User();
if ($User->loggedin = 'true') header('Location:MyAccountNEW.php');
The issue is this redirects to myaccountnew.php weather I switch it to true or false.. (although it does not when the condition is (2>3). Aslo when I echo $User-loggedin, nothing comes up. I'm kinda stumped...
Heres the class
Class User {
public $loggedin = false;
public $username = "";
public $ShopperID = "";
function __construct() {
$this->CheckLogin();
}
function CheckLogin() {
if (!empty($_SESSION['LoggedIn']) && !empty($_SESSION['Username'])) {
$this->loggedin = true;
$this->username = $_SESSION['Username'];
}
else {
$this->loggedin = false;
}
}
heres what logout.php looks like
<?php include ("base.php");
include("userclass.php");
$User = new User();
$User->loggedin = false;
$_SESSION = array(); session_destroy(); ?>