Skip to content

Uses for check users online, user's last activity, last ip and other user's information

Notifications You must be signed in to change notification settings

janbolat/DbHttpSession

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

DbHttpSession

Stores session data in database and transfer data when session is destroy. Uses for check users online, user's last activity and last ip.

Add this to component section in config/main.php

'session' => array (
  'class' => 'application.components.DbHttpSession',
  'connectionID' => 'db',
  'sessionTableName' => 'session',
  'userTableName' => 'user'
),

Session table will be created automatically

Add columns to your user table:
ALTER TABLE user ADD user_id INT(11) NOT NULL, ADD last_ip VARCHAR(100) NOT NULL, ADD last_activity DATETIME NOT NULL

For Example:

Add this method to User model

    public static function getOnlineUsers()
    {
        $sql = "SELECT session.user_id, user.name FROM session LEFT JOIN user ON user.id=session.user_id";
        $command = Yii::app()->db->createCommand($sql);
        
        return $command->queryAll();
    }

Wiki http://www.yiiframework.com/wiki/751/check-users-online-user-last-activity-user-last-ip/

About

Uses for check users online, user's last activity, last ip and other user's information

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%