Using magento 2. I want to allow a user customer use only one device at the same time. Example It look like admin login, admin cannot login to other device while they login current device.

2 Answers 2


There is a section "Online Customers" under Customers in Admin.

Here magento shows name, email, ip address, session start time, last activity and last url accessed.

you can call 'Magento\Customer\Model\Visitor' model and get list of all currently online customers/ visitors.

Now whenever a customer logs in, you can make a custom observer and call its function to match email of that customer with all this data you got from model.

and logout cutomer from previous device if you find a record same.

Hope it helps.

  • Do you have any sample code? Commented Jun 28, 2018 at 9:41
  • Unfortunately no.
    – mighty_hk
    Commented Jun 28, 2018 at 11:04

Well, it’s simple enough. You can create Event/Observer that hook into the event: customer_login and check as follows in the observer method:

$customer = $observer->getEvent()->getCustomer();
$log = Mage::getModel('log/visitor_online')->getCollection()->addFieldToFilter('customer_id', $customer->getId())->getFirstItem();
if($log->getId()){ //current user is already logged in / online from another location
    $session->addError(Mage::helper('customer')->__('Customer with email (%s) is already logged in.', $customer->getEmail()));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.