How to check if the user is logged in Drupal 6 using php

I needed this snippet of code in a block to show different links based on the user's logged in state.

  1. <?php
  2. global $user;
  3. if ($user->uid) {
  4.     print "logged in";
  5. }
  6. else if (!$user->uid) {
  7.     print "please log in";
  8. }
  9. ?>
Technology: 

Add new comment