Jump to content

Recommended Posts

How do forums check if you've read a post or not? Is it through cookies?

 

PHPFreaks uses an army of insects, looking over your shoulder to see which posts you're reading, who then report back to the forum server via your wifi (or tapping into your modem directly).  Sometimes they eat cookies, if the cookie jar is left open… they've got to eat something!

 

 

too do this you would create a colume in the database like read with data type of int and you would simply do a qury like Selete post_comment FROM posts WHERE read = 1 that would then display all posts that have been read and same gos for WHERE read = 0

But there's thousands of users with thousands of posts, so I'm wondering how you store this data in the database efficiently.

 

One way I thought of is to insert a new row into a table whenever a user has read a post for the first time, but then this could potentially have millions and thousands of rows and seems to be inefficient IMO.

 

What's a way to do this better?

i think people have been getting confused by what you meant. am i to understand you want to check if a registered user has read a post(something that they chose to be notified about or are following) like when phpfreaks shows you new replies to your posts, then once you have read them the links dissapear. if so then cookies is the way to go.

i think people have been getting confused by what you meant. am i to understand you want to check if a registered user has read a post(something that they chose to be notified about or are following) like when phpfreaks shows you new replies to your posts, then once you have read them the links dissapear. if so then cookies is the way to go.

 

Yes like on these forums, when you go to a page like http://www.phpfreaks.com/forums/php-coding-help/

 

You can see that some threads have "new" written on the side of them with orange background. I just wanted to figure out how the forum decided to show which ones were new and which ones were not new.

 

And if you say its through cookies, won't that possibly mean that the forum is going to set a ton of cookies?

without having access to the SMF(software phpfreaks uses) database its hard to figure out. the cookie names generated by SMF arent clear about what they are but theres only about 4 or 5 of them so i dont think its cookies.

too do this you would create a colume in the database like read with data type of int and you would simply do a qury like Selete post_comment FROM posts WHERE read = 1 that would then display all posts that have been read and same gos for WHERE read = 0

 

I wouldn't hold the column in the posts table otherwise it will be flagged read for every user once one opens it.

i think people have been getting confused by what you meant. am i to understand you want to check if a registered user has read a post(something that they chose to be notified about or are following) like when phpfreaks shows you new replies to your posts, then once you have read them the links dissapear. if so then cookies is the way to go.

 

And then I close my browser*... all posts marked unread.. darn, I'll have to start all over again :)

 

(*) I have my browser set to destroy any and all cookies regardless of expiration date.

It would be impossible to keep a list of ALL the posts viewed or not-viewed (depending on if you are a optimist or a pessimist) for each member.

 

This is done by keeping a 'bookmark' (imagine that you are reading a book where pages (posts) are constantly being added to the end of the book) of the highest post id where the member has previously viewed all the posts up to that point and displaying the 'new' icon for posts that are greater than that bookmarked post id that have not been viewed yet.

 

You only need to keep a smaller database table of the 'viewed' posts that have an id greater than the bookmarked post id. As new posts are viewed, their id is added to the table and the 'new' icon is not displayed for them.

 

I'll leave the logic of when you advance the bookmark and clear entries out of the smaller table up to you (I wish SMF had gotten it right in all situations.)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.