Welcome Guest ( Log In | Register )




                Web Hosting

 
Reply to this topicNew Topic
Php Forum Cookies, I need help on a php forum cookie. All suggestions welcome.
sparkx
post Aug 3 2007, 01:29 AM
Post #1


Sparkx
Group Icon

Group: [HOSTED]
Posts: 371
Joined: 11-October 06
From: Dana Point, CA, USA
Member No.: 16,496
myCENTs:0.61


OK, I am making a forum in php (with a mysql database). It is much harder then I thought it would be but I have been getting along very well. I was just putting some finnishing things on it when I found a problem I couldn't figure out. All suggestions are welcome.

Problem: I want my forum (like all forums) to remember what topics you have already read. I want to do this via cookies and at first I was think of having to topic ID to be saved in a string. Example (Cookie: %x%) x=the forum topic ID. Then to retrieve that data I would simply look for %x% inside the cookie. 
If it was found then the forum would be marked as read otherwise it would appear unread. 
Now there are some problems that are very obviouse with this method.
1: New posts would not make the topic appear unread.
2: No way to mark all posts (well it would take lots of bandwidth at least).
The two ways I was thinking would require a large cookie and I dont feel right adding long cookies to people's computers.
1: Add the time that the topic was read example (cookie: %x-t%) x=forum topic ID t=internet time.
2: Instead have every post ID in the cookie rather then only the topic ID. Example (cookie: %y%) y=reply/post ID

What would you suggest? Are my two way listed the only ways or is there a more effective way that would require a smaller cookie? Once again all suggestions are welcome.
Thanks,
Sparkx
Note: Sorry about some odd spacing around the center of this topic. I was having trouble with my computer.
Go to the top of the page
 
+Quote Post
vizskywalker
post Aug 3 2007, 01:39 AM
Post #2


Techno-Necromancer
Group Icon

Group: Members
Posts: 1,018
Joined: 13-January 05
From: The Net
Member No.: 2,127


Umm... there are probably lots of ways to do that via cookies, but all of them would require large cookies. Except one I can think of, which would be a compression/hash algorithm that could take every post and its state, compress it into a hash of some sort, and then decompress it when the server gets the cookie back to retrieve that information. but good luck accomplishing that, especially in any reasonable amount of time. As far as I know, most forum software does that kind of thing on the server's end, not via cookies, associating accounts with whether posts have been read or not. there are several reasons for this:
1) It is nicer to the users.
2) It means that the users information is preserved across multiple computers.
3) It is usually faster.

Also, most forums I know simply keep track of a new message state, rather than a read/unread state. This is a lot easier to do, as it just keeps track of last time logged in, and any posts made after that get marked new.

~Viz
Go to the top of the page
 
+Quote Post
yordan
post Aug 3 2007, 08:51 PM
Post #3


Way Out Of Control - You need a life :)
Group Icon

Group: [MODERATOR]
Posts: 2,292
Joined: 16-August 05
Member No.: 7,896
myCENTs:99.39


I think the coookie could have simply a number.
This number could be the numID in the numID column of a table (obtained for instance with an NEXT_ONE algorythm). The other columns would be the username (confirmation), the last read topic identification, and for instance the previous numID.
Then, a single small info would be stored in the cookie, all other info's would be in tables inside the database.
Go to the top of the page
 
+Quote Post
sparkx
post Aug 7 2007, 01:15 AM
Post #4


Sparkx
Group Icon

Group: [HOSTED]
Posts: 371
Joined: 11-October 06
From: Dana Point, CA, USA
Member No.: 16,496
myCENTs:0.61


Thank you vizskywalker and yordan. I like the idea about keeping read and un-read on the server. I am thinking about maby keeping track of Topic ID and Viewed Date (for each topic) on my server connected to the user. I will simply have all un-read posts for guests (no cookies). The only problem with checking the login date is that the user did not neccissarly read all the posts on the last login, but then again it takes up a lot less space on my server.
Thanks again for all the help. I was really stuck on this problem,
Sparkx
Go to the top of the page
 
+Quote Post

Reply to this topicNew Topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Collapse

> Similar Topics

    Topic Title Replies Topic Starter Views Last Action
No New Posts 5 Kid Saiyan 1,858 3rd January 2009 - 07:11 AM
Last post by: iG-curtis
No New Posts 14 ScriptMan 1,177 29th December 2008 - 08:17 AM
Last post by: surg
No new 26 FirefoxRocks 2,265 27th December 2008 - 05:47 AM
Last post by: jlhaslip
No new   21 khalilov 1,792 6th December 2008 - 12:26 PM
Last post by: yordan
No new   27 Vagodeoz 5,344 26th November 2008 - 03:21 PM
Last post by: Michalak
No New Posts   12 Vyoma 1,874 13th November 2008 - 01:42 AM
Last post by: Guest
No New Posts   7 LegallyHigh 567 1st November 2008 - 06:57 AM
Last post by: Jezstarr
No New Posts   2 yordan 455 18th October 2008 - 03:01 PM
Last post by: yordan
No new   23 Aditya 5,388 29th August 2008 - 01:41 AM
Last post by: skedad
No New Posts   8 hihihihi88 1,843 30th July 2008 - 09:48 PM
Last post by: Guest
No New Posts   2 iWolf 422 2nd July 2008 - 05:03 PM
Last post by: Quatrux
No New Posts   12 Dream 8,792 22nd June 2008 - 10:46 PM
Last post by: iGuest
No New Posts   2 LegallyHigh 519 19th June 2008 - 08:41 AM
Last post by: Atomic0
No New Posts   4 Miles 662 18th June 2008 - 07:07 PM
Last post by: sparkx
No new   22 RunerNMage 10,689 22nd May 2008 - 02:14 AM
Last post by: iGuest