Re: incrementing cookie

From: Date: Wed, 14 Sep 2005 12:57:44 +0000
Subject: Re: incrementing cookie
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-222384@lists.php.net to get a copy of this message
Ross wrote:
Hi, I want to increment a cookie by 1 every time a click a button if (isset($add) { $number++; setcookie("cookie[number]", "$number Is the number") } I know I should retireve the cookie value for $number but the problem is it has 2 bits, a number and a bit of text.
in your case this can be done simply: $number = 99; $string = "$number Is the number"; echo "the number is ",intval($string),"\n"; this works because the number is at the start of the string... (and because of the cool way the made type conversion work in php) to find out more search/read the manual on the subject of typecasting/conversion.
Thanks, Ross


« previous php.general (#222384) next »