I am trying to create some javascript function and I need to check if users are logged in or not. When a user logs in to my site, I set a variable in the session array called is_logged. I want to achieve this variable in javascript, is this possible ??? I tried several ways, but did not work as shown below:
var session = "<?php print_r $_SESSION['is_logged']; ?>"; alert(session);
and
var session = '<?php echo json_encode($_SESSION['is_logged']) ?>'; alert(session);
It either shows the text or never warns at all
source share