I want to know how to get the number of users currently online or having active sessions on a website using Zend Framework.
I tried the usual way of reading Session save path, but its not working using Zend. Can anyone here suggest me a good method to know how many active sessions are on the server at any moment of time.
Instead of create base controller and extend all other controllers from that, we can create and use Zend Front Controller plugin ( see examples here) to register all request to our website or web application.
Then we count active users and much more.
You can't use sessions to do this, you would have to store the online users in a DB and display all who are active.on log out delete/update records from db.
or put a flag in ur users table and update flag as y/n every time a user logged in / log out.
or something similar to this.
If user closes browser without logout then when next time user tries to log in. u can check previous active sessions for that user, if there? give a window to user that last logout was not correct and take any event from that user to update time or u can ask user to enter log out time (estimated) for late session or if users are not interested to select time u can update logout with a logout time . make a slandered interval of login duration.
think like this way......
Recently had that problem. Solved it like this:
Usually a controller is an extension of Zend_Controller_action, for example
What we did in our project was create an extended controller under /library/ME/Controller
Using this controller you can extend all your other controllers from it - so, the above default controller goes from
to
Important, remember to always call parent::init() in the init() section of your controller (this is good practice anyway)
Now you can add any code you like to the "Base" controller. As we are using Zend_Auth with a Doctrine user object, the final "base" controller looks like this
The update() method just sets an "updated" field to the current date and flushes the user. You can then just select users who were seen within the last X minutes to show the list.