How to check another user is logged in? There is a lot of questions how to check the current user is logged in, but I need to check another users (by uid for example).
Is there any easy way to do it?
There aren't any functions in Drupal that I am aware of. You'll need to query the database.

$time_active = db_query("SELECT timestamp FROM {sessions} WHERE uid = :uid ORDER BY timestamp DESC LIMIT 1", array(":uid" =&gt; $uid))-&gt;fetchField();


That will fetch the last time that the user was active if they have a current session open.