10-25-2008, 01:57 PM
|
#5 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Here's how to do it with sessions:
php Code:
<?php public function user_login ($user_id) { $sql = sprintf(" UPDATE `%s` SET `%s` = '%s', `%s` = NOW(), `%s` = NOW() WHERE `%s` = '%d'", $this-> db-> table[ 'users'], $this-> db-> col[ 'user_session'], session_id(), $this-> db-> col[ 'user_last_visit'], $this-> db-> col[ 'user_last_action'], $this-> db-> col[ 'user_id'], $user_id); $this-> db-> query($sql); } public function user_is_active () { $sql = sprintf(" UPDATE `%s` SET `%s` = NOW() WHERE `%s` = '%s' LIMIT 1", $this-> db-> table[ 'users'], $this-> db-> col[ 'user_last_action'], $this-> db-> col[ 'user_session'], session_id()); $this-> db-> query($sql); } public function is_user_logged_in () { $sql = sprintf(" SELECT `%s` FROM `%s` WHERE `%s` = '%s' LIMIT 1", $this-> db-> col[ 'user_id'], $this-> db-> table[ 'users'], $this-> db-> col[ 'user_session'], session_id()); $query = $this-> db-> query($sql); if(@ mysql_num_rows($query)) { return true; } return false; } public function user_logout () { $sql = sprintf(" UPDATE `%s` SET `%s` = '' WHERE `%s` = '%s' LIMIT 1", $this-> db-> table[ 'users'], $this-> db-> col[ 'user_session'], $this-> db-> col[ 'user_session'], session_id()); $query = $this-> db-> query($sql); if(! $query) { return false; } return true; }?>
__________________
|
|
|
|