Page 1 of 1

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

Posted: Mon Jun 09, 2003 12:57 pm
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?

Posted: Fri Jun 20, 2003 12:47 pm
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..