Skip to main content
added 50 characters in body
Source Link

You can use the session functionality in PHP to determine if a user is logged in or not.

">

<?php
session_start();

if (isset($_SESSION['logged_in']) && $_SESSION['logged_in'] === true) {
  $link = '/my-account.php';
  $text = 'My Account';
} else {
  $link = '/login.php';
  $text = 'Login';
}
?>
<a href="<?php echo $link; ?>"><?php echo $text; ?></a>

You can use the session functionality in PHP to determine if a user is logged in or not.

">

You can use the session functionality in PHP to determine if a user is logged in or not.

<?php
session_start();

if (isset($_SESSION['logged_in']) && $_SESSION['logged_in'] === true) {
  $link = '/my-account.php';
  $text = 'My Account';
} else {
  $link = '/login.php';
  $text = 'Login';
}
?>
<a href="<?php echo $link; ?>"><?php echo $text; ?></a>
Source Link

You can use the session functionality in PHP to determine if a user is logged in or not.

">