开发者

The way to read many cookies

I'm storing a cookie for user if he did view the thread - the cookie contains unix time of the last post in each thread, then I'm comparing the time between actual cookie data and the threads last post.

Every nice forum, has a default page with sections and forums list. Now how to read those cookies I was stored for such post in each thread of a forum?

I was thinking at something like:

foreach( $threads as $thread ) {
 if($_COOKIE[@PREFIX."_thread".$thread['id']] < $thread['lastpost'])
   //do action , in case if there are some new posts
 else
   //do action, in there aren't new posts.
}

I开发者_JAVA百科'll have to parse now 10 and later even thousands of threads. Will it hurt alot the server performance?


I don't think this is a good way to do this based on the fact that no forum software does. For one, if the user clears the cookies, or uses a different browser then all this will be lost.

Assuming you have a thread and user table I would add another table to record when they last saw that thread.

TABLE user_thread_view
{
    thread_id
    user_id
    created (timestamp)
}

Then when you pull out the list of threads on that forum (which is 10-20 per page) you can add a call into this table to see if the "created" match for this user and thread is less than the current last_modified of the thread.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜