Yii Framework Forum: Single Session Allowed For A User - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Single Session Allowed For A User Is it possible to have user login only once Rate Topic: -----

#1 User is offline   Anirudh 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 21-February 13

Posted 17 April 2013 - 08:57 AM

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.
(Yii::app()->session->sessionID)

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'));
Yii::app()->session->setSessionID($oldslog->session_log_sessid);
Yii::app()->session->destroy();
     
       return true;

   }


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

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users