2

I have been working on a site that requires users to be logged in and approved before they can access the website. That element works fine, except if as an administrator I edit the customer's account to revoke their access.

Refreshing the page as that (already logged in) customer, I expect to be logged out and redirected to the login page. Instead, I am able to continue to remain logged in.

I have been looking for a way to try and programatically (on save of customer) to log that customer out.

$session = Mage::getSingleton('customer/session');
$session->loginById($customer->getId());

// Log Out the customer.
$session->logout();

This I have been trying to use, unfortunately, instead of logging out the customer, it logs me out from the admin instead.

So it seems that I need to have something like $customer->getSessionId() and load the session from that, but that doesn't seem to exist as a route.

As an alternative work around, I expect it might be possible to override the session itself on reinitialise on the customer view, but this feels like it might be unnecessarily convoluted.

3

In the end the solution that was deemed suitable for my requirements has been to validate the user on the front end request. When the user account has been logged in, we check to see if the account is still enabled, if its not log them out from their own session and redirect to login page.

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.