Question

I've written my own discussion software (it works quite nicely), but I have had a feature request from one of our users to mark discussions "since my last visit" as new. (Currently, we simply mark any discussion item updated in the last 24 hours as new.) So...

How do I calculate the date/time that a user "last visited"?

  • Users may remain logged-in, so I can't use the "last logged-in" time: since this might be weeks or months in the past.
  • If I update a user's record on every page-load, then 'since my last visit' will be 'since my last page load', which clearly won't work.

What's the typical way that forum software works out a "last visit" date/time?

Was it helpful?

Solution

We persist "views" of posts by the users. A view relates a post to a user and a time stamp. When a user loads a page, any posts displayed on that page are marked as viewed by that user, if they have not been viewed already. Then, new posts are simply those which have not been seen by the user yet.

OTHER TIPS

You could see if it's been a few hours since last page load, or a day.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top