Get User logged in count query

Get User logged in count query

by Leena Nikhare -
Number of replies: 4

Hi,


I am using moodle 3.3 for windows server.

I need the query to fetch count of logged in users.


Regards,

Leena Nikhare

Average of ratings: -
In reply to Leena Nikhare

Re: Get User logged in count query

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

There's a block you can add to (for example) the home page - called 'Online users'. 

Note that it really only shows you how many people used the the system in the last 5 minutes. Moodle doesn't 'know' who is logged in. That's done by sessions. 

In reply to Howard Miller

Re: Get User logged in count query

by Leena Nikhare -

Hi Howard,


From which Moodle folder session data is getting fetched.

Can you please tell me how does it work?


Regards,

Leena Nikhare

In reply to Leena Nikhare

Re: Get User logged in count query

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

You can't... it works the other way around. Session cookies in the browser control logins. You can't detect that. 

That's why the block looks at users who have interacted with the site in the last few minutes. It's the best approximation you can get. 

You *could* check that users have logged in - that is the event of them logging in but it doesn't do you any good. There's no stateful data to say they are "logged in now". It's not really a sensible question when it comes to web applications unfortunately. 

In reply to Howard Miller

Re: Get User logged in count query

by Leena Nikhare -

Hi Howard,


Does moodle store any data for logout?

I mean if any user log out record is there stored in database.