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

free web hosting
Free Web Hosting > Computers & Tech > Programming > Scripting > PHP

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

sparkx
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.

 

 

 


Reply

vizskywalker
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

Reply

yordan
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.

Reply

sparkx
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

Reply


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

Similar Topics

Keywords : php, forum, cookies, php, forum, cookie, suggestions,

  1. How To: Make A Simple Php Forum System
    (4)
  2. Free Forum Hosting Type Script Help!
    Free forum hosting type script help!!! (2)
    i want to make something like http://invisionfree.com/ that makes an dir with your phpbb 3 forum
    in it with an admin CP plz help i really want to make something like it!! i was thinking of coding
    my own with file handling but i'm not good at some of it like "when u click submit to register
    a forums it will move the phpbb3 file that leads to the users dir then it will rename the dir to
    your username so like my.site.com/username it might work" with the admin username and pass and
    admin's email it will open the config.php then edit all the data but it will ke....
  3. Already Sent Session Cookies?
    (2)
    Er, this is the second topic I've posted about session problems. Here's the html file that
    keeps showing up: CODE Warning: session_start() : Cannot send session cookie - headers already
    sent by (output started at C:\Program Files\xampp\htdocs\index2\loggingin.php:2) in C:\Program
    Files\xampp\htdocs\index2\loggingin.php on line 39 Warning: session_start() : Cannot send session
    cache limiter - headers already sent (output started at C:\Program
    Files\xampp\htdocs\index2\loggingin.php:2) in C:\Program Files\xampp\htdocs\index2\loggingin.php on
    line 39 Fatal ....
  4. Random Name Generator
    For a fantasy RPG forum (2)
    Well, I did this particular piece of coding a few days back, and I forgot to display it to you all
    here at AstaHost. I have just started a fantasy RPG forum. The naming rules are pretty strict
    because it has to be based on a construted langage called Pasen. No matter how much I explained, I
    thought, it would be hard for a newbie to understand the syllable formation constraints. Hence, I
    wrote a script and put it at my Drupal powered site, that generates random names for the four races
    for both genders. http://www.WiseTome.com/name-generator-for-chaos-and-order I ....
  5. Wordpress With Forum ?
    (2)
    Is there any software or MOD that could integrate WordPress with a forum ? I mean the posts /
    comments / User DB. I know of a site that makes a script called XDForums , but it supports WP 1.5
    not 2.0 .. and i have the latest version of WP installed. Plus the site is taking loads of time to
    release a new version of the forum software. Does anyone know a MOD that could integrate PhpBB
    forums to wordpress with the user DB etc .. ?? or could someone be kind enough to code it ? Thankx
    Regards Dhanesh. ....
  6. Sessions, Setting, Unsetting, Reading
    and in combination w/ cookies (5)
    I am making a login script which atm uses a cookie to set login status. I would like to include
    sessionwise checking into this. And also an IP check, where i write the IP to database and later get
    it for all other pages and then check it up to the client for each page. I need to know the
    commands for: - getting an IP - Starting a session - Ending a session - Reading a session....
  7. How To Remove A Cookie Using PHP
    (1)
    Hi :-) How can i remove a cookie from $_COOKIES array ? P.S.: sorry it there is any mistakes in
    my english :-) Topic title edited to suit the nature of content better. In future try to make
    your topic title more descriptive. ....
  8. How To Use Cookie In Your Web Site ?
    this semple code to use and get cookie (1)
    what is the cookie ? the cookis it is some info sent and save in user computer whare i can use the
    cookies? becouse the cookies it like the header you can not send it after any output wes sent so
    you must send the cookies before any output like as ,echo and any other code i well make an E.X.
    to use the cookies you must have 2 file index.php update.php ---------- in the index.php add this
    code CODE    // This section must go at the top of the page that will display    // the
    users favorites.  These are the 'default' URLs that the user    // will se....
  9. Forum Signature-image With Php
    Use PHP to create an image in real-time (8)
    With interest I have read these Topics. What I want to do with PHP is the following:
    Signatue-image This is the Forum Signature of my cousin, who lives in Europe. The image is
    generated in real-time. (Refresh the page, and see for yourself) My cousin refuses to tell me how
    he did this. But I want to do the same thing, also with PHP. Any ideas? Greetings, John. This
    is NOT a tutorial and in future you should be more careful about where you're posting your
    threads. Moved to Programming > Scripting. ....
  10. Script to allow only members to download media
    from a forum/board.. How to do it ? (18)
    I didnt know where to post this so i posted it here I wanna to know where to find a script where
    people have to register at your forum to download media off your website and i also wanna know what
    it is called. ------------------------------------------------------------- Next time you make a
    post - please be more specific about the topic. It helps a lot if your topic describes your post
    content in brief rather than having a "Help me" - which could mean anything. More often this
    wouldn't pique the interest of the readers at all and your post will get very few respo....
  11. How To Do The Security Confirmation
    see it when i register forum (3)
    How to do the security confirmation. When i register this forum, i see this. The image contain
    numbers and user must be fill in the number in image.....

    1. Looking for php, forum, cookies, php, forum, cookie, suggestions,






*SIMILAR VIDEOS*
Searching Video's for php, forum, cookies, php, forum, cookie, suggestions,
advertisement




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