08-01-2018, 02:15 AM
Thank you Brandin for your reply,
Actually what I wanted was if a user tries to login from a device but is already logged in from another device earlier, let him log in from this device but log him out from all other devices. For the solution I thought of the way below but I am not sure if its possible or not.
I may need to one of the following custom script but not sure which
1. not_logged_in.php // I may not get a handle to User class here
2. custom_login_script.php // I get a handle to User class here
I checked logout.php and it uses
When I checked "User.php" class I found it uses DB to log him out
I am not very good at PHP but figured out I need to somehow combine these and use it in one of the two custom login script to get my result.
Hope to get right direction from you.
Thank you.
Actually what I wanted was if a user tries to login from a device but is already logged in from another device earlier, let him log in from this device but log him out from all other devices. For the solution I thought of the way below but I am not sure if its possible or not.
I may need to one of the following custom script but not sure which
1. not_logged_in.php // I may not get a handle to User class here
2. custom_login_script.php // I get a handle to User class here
I checked logout.php and it uses
Code:
$user->logout();
When I checked "User.php" class I found it uses DB to log him out
PHP Code:
public function logout(){
$this->_db->query("DELETE FROM users_session WHERE user_id = ? AND uagent = ?",array($this->data()->id,Session::uagent_no_version()));
Session::delete($this->_sessionName);
Cookie::delete($this->_cookieName);
session_unset();
session_destroy();
}
I am not very good at PHP but figured out I need to somehow combine these and use it in one of the two custom login script to get my result.
Hope to get right direction from you.
Thank you.