Single Session Allowed For A User

Hi everyone,

I have a application with is using sessions and cookies are disabled : ‘allowAutoLogin’ => false;

I’m trying to create a functionality as follows:

When a user logs in I store the session id of the user in the database.


Now when a user tries to login from a different browser or IP address the previous user session should be deleted before new session created during login.

public function beforeLogin($id, $states, $fromCookie)




$oldslog =  UserSessionLog::model()->findByAttributes(array('account_id'=> $states['account_id'] ), array('order' =>'session_log_id DESC'));




       return true;


But there is no success. Is this method the right way or there is a better way to do the same. :rolleyes: