Jump to:

23376 Posts in 18218 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » currently online visitors counter?

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1200 Views
  • Kalileo
    Avatar
    Community Member
    127 Posts

    currently online visitors counter? Link to this post

    Have searched up and down, but there seems to be no built in way to show the count of "currently online unique visitors". (NOT a hitcounter!)

    Before I reinvent the wheel, is there a silverstripe solution available already?

    Not that I like such counters, but it is a customer requirement ...

  • Willr
    Avatar
    Forum Moderator
    5489 Posts

    Re: currently online visitors counter? Link to this post

    The forum has such a feature (as you can see in the footer. How this works is not 'online' as such but people who have logged in in the last 15min. If you're logged in it updates the LastVisited time on every page visit so you can do something like.

    function CurrentlyOnline() {
       return DataObject::get('Member','LastVisited > NOW() - INTERVAL 15 MINUTE');
    }

  • Kalileo
    Avatar
    Community Member
    127 Posts

    Re: currently online visitors counter? Link to this post

    Thanks, Will, yes for logged in visitors this is an easy solution.

    I assume I have to create a table to keep track of the IPs of all visitors (not forum, not logged in), that'll give me something similar, and to avoid that table getting too big to delete old entries from time to time.

  • Willr
    Avatar
    Forum Moderator
    5489 Posts

    Re: currently online visitors counter? Link to this post

    Yes you would have to keep a separate system for managing IP visitors. Deleting old entries from that table after like 3 days would be smart as well.

    1200 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.