Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

Starts at just $1 per CPM or $0.10 per CPC.

Detecting if logged in daily

a data will be inserted in db if a user log in every day, like if he logged in anytime on March 6 it will insert a row, and then again if he log in again any time on March 7 it will add another row again, continue like this. So trying to detect if user returning and login to site within every 24 hours or not. Like in some online games users get reward if they login every day.

Without knowing the platform or database or anything, it'll be a vague answer... but all you'd do is something like this:

Add a line to your login script that calls a function (record_login or something) when their login is successful.

The record_login checks a table of logins and sees if there's a record for today.

If not, it adds a line to a table with today's date. php has a date() function that you can use to store today's date in any format.

Step 2 is the important bit because you only want a single line for each date. That way, you can check logins either by counting the number of entries (for things like "10 logins in the last 14 days") or by recursively stepping back through dates and checking each one exists in turn. Or by pulling all dates between certain limits into an array and stepping through that to see if there's one for each day. Or some other method. It could get quite slow to check through over time, of course.

Alternatively, if you're only interested in continuous daily logins, store a field with the number of days and the last login date, linked to the user id:

Same as above.

The record_login function checks the last login date.

If last login was yesterday, then increment the number of successive days logged in.

Otherwise set to 1 day.

That way you don't have any specific date info to store, your table only ever has one line per user and it's VERY fast to check. But you don't have the login history, should you ever want it for anything.

You could, in fact, mix both methods and use the second for a quick check with the first as the full data version if you ever need to look through their login history - just link both tables to user_id and it'd work.

There are dozens of ways to do it, depending on what exactly you want to achieve.