读取多个cookie的方法
如果用户确实查看了该线程,我会为他存储一个 cookie - 该 cookie 包含每个线程中最后一个帖子的 unix 时间,然后我比较实际 cookie 数据和线程最后一个帖子之间的时间。
每个不错的论坛都有一个包含部分和论坛列表的默认页面。现在如何读取我在论坛的每个线程中为此类帖子存储的cookie?
我在想这样的事情:
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.
}
我现在必须解析 10 个,以后甚至数千个线程。会严重影响服务器性能吗?
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'll have to parse now 10 and later even thousands of threads. Will it hurt alot the server performance?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这不是一个好方法,因为没有论坛软件可以做到这一点。其一,如果用户清除 cookie,或使用不同的浏览器,那么所有这些都将丢失。
假设您有一个线程和用户表,我会添加另一个表来记录他们上次看到该线程的时间。
然后,当您提取该论坛上的线程列表(每页 10-20 个)时,您可以向该表添加一个调用,以查看该用户和线程的“创建”匹配项是否小于当前的 last_modified线。
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.
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.