set_transient('users_status',$logged_in_users,900);//Set this transient to expire 15 minutes after it is created.
}
}
//Check if a user has been online in the last 15 minutes
functionis_user_online($id){
$logged_in_users=get_transient('users_status');//Get the active users from the transient.
returnisset($logged_in_users[$id]['last'])&&$logged_in_users[$id]['last']>time()-900;//Return boolean if the user has been online in the last 900 seconds (15 minutes).
}
//Check when a user was last online.
functionuser_last_online($id){
$logged_in_users=get_transient('users_status');//Get the active users from the transient.
//Determine if the user has ever been logged in (and return their last active date if so).