Check if user is online I need to display an image when a user is online. Like the button of skype that it say if the user is online on skype's system. 

How can I "check" if a user is online ? Is there a light module or I need to create a new one ? I don't need any type of block o stats about this user, only know if he is online or not.

Thanks.
For readability, and simplicity, I like to use the core API:

Check if current user is authenticated

user_is_logged_in()

i.e:

if (user_is_logged_in()) {
  // User is authenticated
  print $content;
}


You can also use

if (!user_is_logged_in()) {
  // User is anonymous
  print $content;
}


though there's even a user_is_anonymous() function

if (user_is_anonymous()) {
  // User is anonymous
  print $content;
}


Check if particular user is logged in

If you want to check if a particular user is online

You can use Rules, or hook_user_login to respond to login event

EXAMPLE_user_login(&amp;$edit, $account){
  /* do stuff */
}


or query the session table for that user session uid

// Check if user $uid is online in the last 10 minutes
$online = db_query("SELECT uid FROM {sessions} WHERE uid = :uid AND timestamp &gt;= :time", array(':uid' =&gt; $uid, ':time' =&gt; (REQUEST_TIME - 600)))-&gt;fetchField();