Hi all,
I have a basic member login script working on my website.
Currently, if the user isn't logged in they cannot see certain pages and get redirected to access-denied.php by the following script:
<?php
//Start session
session_start();
//Check whether the session variable SESS_MEMBER_ID is present or not
if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '')) {
header("location: access-denied.php");
exit();
}
?>
However, I am trying to amend this code so that if the user isn't logged in they can see the page but cannot see various elements of the page. Therefore, instead of sending a user to the access-denied.php page, I want to set a variable in the above code which I can then compare with elsewhere on the page (to decide whether to show a certain paragraph for example).
I have got this far...
<?php
//Start session
session_start();
//Check whether the session variable SESS_MEMBER_ID is present or not
if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '')) {
$logged_in = "no"; }
?>
As a test to see if it works I then put the following later in the file...
<?php if ($logged_in = "no") echo 'Not logged into website'; else echo 'Logged into website'; ?>
However, the output always comes through as "Not logged into website", even though I have logged in.
Can anybody see what the problem is?