Simple Coding Problem with $HTTP_COOKIE_VARS

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
creeper101
Forum Newbie
Posts: 1
Joined: Fri May 14, 2010 1:20 am

Simple Coding Problem with $HTTP_COOKIE_VARS

Post by creeper101 »

I have written the following code:

Code: Select all

<?php
if(empty($HTTP_COOKIE_VARS["times"]))
{
	$times=1;
}
else
{
	$times=$HTTP_COOKIE_VARS["times"];
	$times=$times+1;
}
setcookie("times", $times, time()+3600);
echo "This is your $times visit within an hour";
?>
this code should preview like this:

Code: Select all

This is your 1 visit within an hour

and when i will reload the page the '1' will change to '2' and then to '3' and so on.
However when i reload the page it still remains '1' and doesnt show '2'.
is anything wrong in this script?
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Simple Coding Problem with $HTTP_COOKIE_VARS

Post by Benjamin »

Yes, $HTTP_COOKIE_VARS is no longer used.

http://php.net/manual/fr/reserved.variables.cookies.php
Post Reply