Hello! There was a question: at various sites there is a function to read the news, after which the given news will no longer be displayed. The question is: Do I need to create a separate table in the database? If so, it turns out that when creating each news item, you need to create an additional entry in the table with the news and user, and create not one record, but how many users do we have registered?

  • Thank! Now everything is clear! - angers777

2 answers 2

Maybe it’s enough for the user to remember the read news via comma id? Remember infu about N recent read. Suppose the site can display 20 recent news. Then the user in the cookie is enough to remember the last 20 read them. Older ones should be deleted in order not to inflate a cookie.

Upd. I did not add that you need to hide news on the client side with the help of JS. The server distributes to all the same pages. Client's browser is responsible for what to do with the cookies, and what to hide.

  • The option with cookies is good, but what if the user first read at home and then at work? re-cooked read news stuff? you can just redo your option, all the same, only storage in the database - pavelbel
  • Can. The variant with cookies from the philosophy of “drain the maximum load on the client in order not to load the server”. Of course, it is not universal. I did not add that you need to hide news on the client side with the help of JS. Those. the server distributes the same pages to everyone. Client's browser is responsible for what to do with the cookies, and what to hide. - Sergiks
  • duck, again, everything will be bent when changing a client .. but every time I read from the database to check whether or not the list is displayed in a cycle, it’s not really either.

Correct approach to the problem from the reverse side. When creating news, do not add anything to the additional table. But then add one entry at the time of reading the news by a specific user. The fact that there is a record in this table will mean that this user has already read this news. When displaying news, you will simply have to skip those news for which there is already a record of reading by this user.