Unread Posts? (php, but its a Theory question not code...)

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Coco
Forum Contributor
Posts: 339
Joined: Sat Sep 07, 2002 5:28 am
Location: Leeds, UK
Contact:

Unread Posts? (php, but its a Theory question not code...)

Post by Coco »

Im kinda thinking that since this is more a question about cookies and user visits etc.... that it should be here....


Ok, i want to create a system kinda like the one in this forum for showing which posts are new since your last visit...
I understand that the way to do it would be to place the last visit time in a cookie (since this has to work for non-logged in users too)

My question is.... when should this cookie be updated? i mean.... i dont want to update it immediately, cos then the instant you visit the site then everything is 'read'... but then i cant guarantee that the user will be at the site for more than 20 secs...

or am i totally wrong in doing it this way?
User avatar
m@ndio
Forum Regular
Posts: 163
Joined: Fri Jun 06, 2003 12:09 pm
Location: UK

Post by m@ndio »

hi,

Firstly I would store this in the user table in a DB.

What I would do is this:

When the user visits the website and tries to query the database it checks to see if the "last_visited" field (for arguments sake) has a value.. if it doesn't then obviously you are a new user, if it does then highlight all new posts between the last time you visited and now. Finally once the session is ended update the "last_visited" field in the DB when you logout.

Hope this helps..
Post Reply