Forum Moderators: coopster

Message Too Old, No Replies

Session Variables

Session Variables

         

shimeal

4:13 am on Jan 14, 2005 (gmt 0)

10+ Year Member



Hello - I am using an inc.php file on two different pages of my site, one page which is open to the public and one page which requires user access (hence the session variables). I want to insert some PHP code which detects if the user is logged in or not when clicking an internal hyperlink and directs them to either another logged-in page or an open page.

This is the code I currently use on the user-access pages:

<? session_start();
if($_SESSION['CustomerID'] == "") { header("Location: login.php"); }
?>

I am looking for some type of PHP script which says

<?
IF ($_Session['CustomerID'] == "") THEN (HYPERLINK:INDEX-USERISLOGGEDIN.PHP) ELSE (HYPERLINK:INDEX.PHP)
?>

How can I create such a code? How can I have my text with this underlying code look like a hyperlink?

sajannair

7:25 am on Jan 14, 2005 (gmt 0)

10+ Year Member



HI THIS SHOULD WORK....TRY IT OUT AND REFLECT BACK!
<?
session_start();
if($_SESSION['CustomerID'] == "")
{
echo "<a href='login.php'>Your Session has expired! Click Here to Login!</a>";
}
else
{
echo "<a href='userloggedin.php'>Welcome Click Here to Continue!</a>";
}
?>

shimeal

4:20 pm on Jan 14, 2005 (gmt 0)

10+ Year Member



Thank you so much - it worked like a charm!