1

Suppose I have a table with the current users logged in on my website. And if I there isn't any "activity" from one of his/her username in a time interval it would be deleted from the table.

What would be the easiest way to implement this functionality?

Besides using batch files or something like that.

I searched but database triggers can't be timed programmed, at least from what I gathered.

1 Answer 1

2

Usually you would have something like this:

  • A table would have a column named something like last_activity which stores a timestamp of when the user last visited a page

  • You check via a query if a user has been active within a certain amount of time (ex: WHERE last_activity - current_time < 60 [active in the last minute])

Sign up to request clarification or add additional context in comments.

5 Comments

@Mitch Wheat: why to schedule it?
because after the period of no activity might mean they have logged off, in which case you need an 'entry point' to run a process....
nice idea...many thanks for the help...I'll set that present users are those who have done anything in the last 5 mins for example.
@Mitch Wheat: if there is no users on the site - then no one cares about state of activity table ;-) And when someone will enter the site after, for example, 1 hour - all obsolete records will be deleted.
@ zerkms: talk to the poster. I didn't post the question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.