/ Published in: PHP

- Check if any particular customer is currently logged in or not.
- Get all the logged in customers with their recent activity.
- Courtsey: <a href="http://ka.lpe.sh">http://ka.lpe.sh</a>
- Get all the logged in customers with their recent activity.
- Courtsey: <a href="http://ka.lpe.sh">http://ka.lpe.sh</a>
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
require "app/Mage.php"; Mage::app(); $collection = Mage::getModel('log/visitor_online')->prepare()->getCollection(); //Get all the customers that are logged in...... foreach($collection->getData() as $cust) { echo 'Customer ID: '.$cust['customer_id'] . '<br/>'; echo 'Last URL visited: '.$cust['last_url'] . '<br/>'; echo 'First visit: '.$cust['first_visit_at'] . '<br/>'; echo 'Last visit: '.$cust['last_visit_at'] . '<br/>'; echo '======================<br/>'; } //Get any particular customer, if he's currently logged in or not..... $collection->addFieldToFilter('customer_id', 5)->addCustomerData(); //5 is customer ID of customer you want to check echo 'Customer is logged in'; } else { echo 'Customer is NOT logged in'; }
URL: http://ka.lpe.sh/2013/04/25/magento-check-if-any-particular-customer-is-currently-logged-in/
Comments
