There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
A sticky problem involving cookies


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
vidyaishaya's Avatar
Member with 71 posts.
 
Join Date: Oct 2001
20-Apr-2006, 06:13 PM #1
Unhappy A sticky problem involving cookies
I've got a sticky little problem in my PHP programming.

I'm writing a commenting system on an article CMS. It uses
PHP and MySQL. Articles are stored in a database. Comments
are also stored with an ID relationship that 'points' at a given
article that has the comments on it.

Each of the comments on a given article, has to have a [NEW] tag next to it
when the logged-in visitor looks at that page again, and hasn't seen a recent
comment on that particluar article. I'm trying to figure out how to do this.

I thought it was a question of comparing the date of the last time the article
was read, to the date of creation of the comment being displayed. So how to
save the date of the last time the article was read? By a logged-in visitor.
That implies cookies.

I mean, it has to imply cookies because we're talkling about a individual visitor.
If we store anything in the database itself, that would apply to all visitors.

But a cookie that stores the time for each and every article the visitor may have read?
What if there are hundreds of articles being read?
Wouldn't the cookies hit their maximum limit pretty quick?

I gotta say -- I can't quite figure out how to do this.
Any suggestions would be appreciated.

Thanks

....Vidya
www.webwisesage.com
treydx's Avatar
Senior Member with 112 posts.
 
Join Date: Jan 2006
Experience: Intermediate
21-Apr-2006, 01:01 PM #2
Quote:
If we store anything in the database itself, that would apply to all visitors.
Not if you stored it in the "Users" table.

I assume you're storing a "Last Logged In" field, right? And I also assume you're storing a "Comment Created On DateTime" field, right? So you have your comparisons right there, forget about cookies completely.

If "CommentCreatedOn" > "LastLoggedIn" then echo "<img href="new.jpg" />"

Take note that if you do this, you need to put "LastLoggedIn" into a session variable BEFORE you update it when they log in
vidyaishaya's Avatar
Member with 71 posts.
 
Join Date: Oct 2001
21-Apr-2006, 01:23 PM #3
Duh! Good one!

Now that I see it, it's like, "well, of course"

Thanks so much.

...Vidya
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 09:44 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.