I need to determine if user is logged in using php. The below code makes sense but is not working - it displays a blank page. I am using the php input filter.

I have also tried to echo the string inside the php code but had the same results. Any ideas?

CiviCRM is installed and the only non-random variable name appearing in the $_SESSION array.

<?
// determine if they are logged in
if(isset($_SESSION['CiviCRM']['userID']){
$link = "http://google.com";
}else{
$link = "/content/join-or-renew-online";
}

?>
if you want to see the content, \">Click here for the content you wish to see....

Comments

arh1’s picture

<?php

global $user;
if ($user->uid) {
  // logged in
}
else {
  // not logged in
}

?>
webdev2’s picture

many thanks!