Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14348

Is my online function OK or does it need improvment?

$
0
0
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]


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);



Viewing all articles
Browse latest Browse all 14348

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>