• Sign in to Neowin Faster!

    Create an account on Neowin to contribute and support the site.

  • 0
Sign in to follow this  

Help on consecutive days logged in


stevember    138
It is relatively simple but I am making it complicated.
I want a counter on a player's profile of how many consecutive days they have been active.
Logged in 51 days consecutively
Longest consecutive period was 68 days
I'm not sure how to store and check.
1. I store their latest online time UNIX every time they refresh the page.
2. Need a function that would update the counter if it has not been updated already that day.
My thoughts are:
Could run a Cron every 24 hours to simply check if their online has been within the last day then either reset or +1. Also check if current consecutive is larger than consecutive record if so copy over.
How would you do it?


Share this post

Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0
articuno1au    1,264

I'd store 2 values: Count and Last Online.

If last online == today -1, count++;

else if last online != today, count = 0;

last online = today/now/whatever;

Run that as a cron and you should be right, alternatively on login or pageload depending on how things are running.

  • Like 1

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.