As a admin in admin panel I want to change status of user account to inactive and after that user should be logged-out from frontend area if he is logged-in. How can I programatically log-out other front-end user by admin from admin panel?
1 Answer
You can get the session save path from app/etc/env.php file.
'session' => [
'save' => 'files'
],
Here, in above code if save_path key is defined, then it will be session path or else you can get it from printing phpinfo() and look for session.save_path
Now what you can do is read all the files contents in that path via PHP code and look for customer_base -> customer_id parameter in that file.
If this customer id matches with your condition, then delete that file programmatically via PHP code in your magento backend.
Note that the content of session file is not simply in serialize format. It is collection of serialize format so you need to write a code that parses the value of customer_id accordingly.
-
I have just created a module for this. You can download it from github.com/yash7690/Magehub_CustomerSessionEnd Try this and let me know if that works for you. Apr 17, 2019 at 20:02