Check for Login Status in Javascript for Drupal

Hello folks.

By default in Drupal 6 you don't have the option to check the login status in JavaScript, if you need this functionality include in your template file i.e page.tpl.php the following code:
 

<?php
global $user;
echo '<script type="text/javascript">';
echo 'var logged_in = ' . ($user->uid)?'true':'false';
echo '</script>';
?>


Now you can use in your JavaScripts the variable logged_in to check user login status

Enjoy It

enzo