Calling a cookie

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: Calling a cookie

Post by twinedev »

Say the cookie contains the timestamp of your visit, so your script could say "You were last here at 5:45pm on August 8, 2011".

You need to read the old value and either store it to another variable or use it right away before somewhere in your script you change its value to be the current time stamp.

If you did it in reverse order, your script would always list your last visit at the time you hit it because you set it to now before reading it.

-Greg
phphelpme
Forum Contributor
Posts: 261
Joined: Sun Nov 21, 2010 3:32 pm

Re: Calling a cookie

Post by phphelpme »

Yeah, basically you will overwrite your existing variable stored in your cookie if you do it the wrong way around.

Best wishes
Post Reply