I want to manage all the logged in instances of a customer and give them an option to log out of all other devices by clicking on a link. What's the way to go about it?

  • You can use Magento oauth. – Aditya Shah Sep 29 '18 at 18:35

You'll have to create a custom module for that in my opinion. In that module you,

  1. Create a customer attribute login_expiry, whose value is initially null.

  2. Add a new value to the customer_session by calling the \Magento\Customer\Model\Session::setData($name, $value) method, called logged_in_at.

  3. Write an observer for the customer_login event and set the logged_in_at value to the current timestamp.

  4. Whenever user opts for "logout from all devices", set the login_expiry value of that customer to the current timestamp.

  5. Write an observer for the customer_session_init event and there check if the logged_in_at value is less than login_expiry, logout the user.

Hope that was helpful. If you require such a module, I have made one previously and could share it with you.

| improve this answer | |
  • Kindly share that module. – Sumit Sep 5 '19 at 13:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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