Answers.Body: <p>Nothing native, so it would have to be with a plugin.</p>
  
  <p>That plugin could listen for the <a href="http://buildwithcraft.com/docs/plugins/events-reference#usersession-onLogin" rel="nofollow">userSession.onLogin</a> event and keep a counter of the number of people that have logged in.</p>
  
  <p>Depending on how accurate you need to be, it gets more tricky when deciding on how/when a user has logged out (either manually or their session expired).</p>
  
  <p>Manually logging out you would need to listen to an onLogout event, that doesn't exist yet, but probably should.</p>
  
  <p>For logging out via session expiration (no activity for the defined <a href="http://buildwithcraft.com/docs/config-settings#userSessionDuration" rel="nofollow">userSessionDuration</a>), you'd need to track the userId that was captured in the <code>onLogin</code> event and periodically check against the <code>craft_session</code> table in the database to see if it still exists.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-15T06:38:37.417Z
Answers.Text: Thanks Brad :)
  It struck me that there may also be some info in the craft_session info that is useful - could that be the case? Or Maybe rather than onLogin, we simply add something to the page in question and store all users who visit that page?
Answers.UserDisplayName: Dan G
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-14T17:07:32.510Z
Answers.LastActivityDate: 2014-10-14T17:07:32.510Z
Answers.UserDisplayName: Brad Bell
Answers.Body: <p>I have added a prototype plugin that uses Pusher.com to keep track of online users.</p>
  
  <p><a href="https://github.com/sjelfull/Craft-WhosAround" rel="nofollow">Check out the Git repo</a>.</p>
  
  <p>Basically you need to add this to your frontend template:</p>
  
  <pre><code>{{ craft.whosaround.setup }}
  </code></pre>
  
  <p>It adds the Pusher library, and also subscribes to the channel name you got in your settings. You need to signup to an account over at Pusher.com as well.</p>
  
  <p>In the CP, you can get a rudimentary list with the name and the count.</p>
  
  <p>I can think of some cool use cases, so I'll probably revisit it soon and add more stuff etc., but it might be a useful starting point, depending on if you want to use Pusher for this.</p>
  
  <p>Pusher is a very neat service for use cases like this, and might be especially interesting if you expect many users online.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-15T15:22:07.627Z
Answers.Text: Thanks Fred - looks great. Can you log who-is-online at all with your plugin?
Answers.UserDisplayName: Dan G
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-15T17:51:16.770Z
Answers.Text: Looks awesome Fred! You may be able to ditch the `raw` requirement: http://craftcms.stackexchange.com/a/1882/45
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-15T21:01:25.957Z
Answers.Text: @DanG: If you include in your frontend, it logs who is online, yes. It's based on this article: http://blog.pusher.com/showing-who-is-online-with-pusher-presence-in-php/
Answers.UserDisplayName: Fred Carlsen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-16T21:49:33.740Z
Answers.Text: Thanks @LindseyD, using the getRaw method now. Smooth operator.
Answers.UserDisplayName: Fred Carlsen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-15T13:59:44.237Z
Answers.LastActivityDate: 2014-10-17T12:38:23.230Z
Answers.LastEditDate: 2014-10-17T12:38:23.230Z
Answers.UserDisplayName: Fred Carlsen
Body: <p>We have a site that is running event pages, that will show live content (via Ustream or similar). Users have to be reg'd and logged in to view content. </p>
  
  <p>We would like to establish who is online and how many logged in viewers at the time of the event. Is there a function that will display this to admin users?</p>
  
  <p>Thanks
  Dan</p>
  
Tags: <users>
Title: Number of users online / Who is online
ThreadText: # Number of users online / Who is online
  
  (Asked by: username_0 on 2014-10-14)
  
  We have a site that is running event pages, that will show live content (via Ustream or similar). Users have to be reg'd and logged in to view content.
  
  We would like to establish who is online and how many logged in viewers at the time of the event. Is there a function that will display this to admin users?
  
  Thanks
  Dan
  
  **Tags:** users
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2014-10-15. Score: 5 | Accepted answer
  
  I have added a prototype plugin that uses Pusher.com to keep track of online users.
  
  [Check out the Git repo](https://github.com/sjelfull/Craft-WhosAround).
  
  Basically you need to add this to your frontend template:
  
  ```
  {{ craft.whosaround.setup }}
  
  ```
  
  It adds the Pusher library, and also subscribes to the channel name you got in your settings. You need to signup to an account over at Pusher.com as well.
  
  In the CP, you can get a rudimentary list with the name and the count.
  
  I can think of some cool use cases, so I'll probably revisit it soon and add more stuff etc., but it might be a useful starting point, depending on if you want to use Pusher for this.
  
  Pusher is a very neat service for use cases like this, and might be especially interesting if you expect many users online.
  
  > **Comments:**
  > **username_0**: Thanks username_2 - looks great. Can you log who-is-online at all with your plugin?  
  > **username_3**: Looks awesome username_2! You may be able to ditch the `raw` requirement: http://craftcms.stackexchange.com/a/1882/45  
  > **username_2**: @username_0: If you include in your frontend, it logs who is online, yes. It's based on this article: http://blog.pusher.com/showing-who-is-online-with-pusher-presence-in-php/  
  > **username_2**: Thanks @username_3, using the getRaw method now. Smooth operator.  
  
  ---
  
  ### Answer by username_1 on 2014-10-14. Score: 2
  
  Nothing native, so it would have to be with a plugin.
  
  That plugin could listen for the [userSession.onLogin](http://buildwithcraft.com/docs/plugins/events-reference#usersession-onLogin) event and keep a counter of the number of people that have logged in.
  
  Depending on how accurate you need to be, it gets more tricky when deciding on how/when a user has logged out (either manually or their session expired).
  
  Manually logging out you would need to listen to an onLogout event, that doesn't exist yet, but probably should.
  
  For logging out via session expiration (no activity for the defined [userSessionDuration](http://buildwithcraft.com/docs/config-settings#userSessionDuration)), you'd need to track the userId that was captured in the `onLogin` event and periodically check against the `craft_session` table in the database to see if it still exists.
  
  > **Comments:**
  > **username_0**: Thanks username_1 :) It struck me that there may also be some info in the craft_session info that is useful - could that be the case? Or Maybe rather than onLogin, we simply add something to the page in question and store all users who visit that page?  
  
  ---
  
  