Jump to content
xisto Community
sparkx

Php Forum Cookies I need help on a php forum cookie. All suggestions welcome.

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.