I would like to know if my code is suitable for checking if user is online seems to work.
When user not online it gets the users time stamp from database by accessing id on profile url.
http://localhost/project/user/1
Does the online function below need any improvement suggestions please thank you.
![[Image: 3DaSi4jx1eND.png]]()
When user not online it gets the users time stamp from database by accessing id on profile url.
http://localhost/project/user/1
Does the online function below need any improvement suggestions please thank you.
![[Image: 3DaSi4jx1eND.png]](http://ibin.co/3DaSi4jx1eND.png)
PHP Code:
public function online($timestamp){
$offline = time() - 50;
if ($this->auth->islogged()) {
return 1;
} else {
if ($timestamp <= $offline) {
return 0;
} else {
return 1;
}
}
}
public function index($user_id = NULL) {
$udata = $this->user_model->getuser($user_id);
$data['active_status'] = $this->online($udata['last_loggedon']);
$data['children'] = array(
'common/header',
'common/footer',
'common/navbar'
);
$this->load->render('user/user', $data);
}