ch1326 Posted May 13, 2009 Share Posted May 13, 2009 hi everyone, I need some help with this code. everytime when i push F5, it keep showing 1 only. what i want is, when I put F5 everytime the value would +1 <?php if (isset ($_COOKIE["numCounter"]) ){ $_COOKIE["numCount"]++; setcookie("numCount", $_COOKIE["numCount"]); } else { setcookie("numCount",1); } echo $_COOKIE["numCount"]; ?> Quote Link to comment https://forums.phpfreaks.com/topic/157962-solved-f5-and-plus-1/ Share on other sites More sharing options...
JonnoTheDev Posted May 13, 2009 Share Posted May 13, 2009 <?php if(is_numeric($_COOKIE["numCount"]) ){ $_COOKIE["numCount"]++; } else { setcookie("numCount",1); } echo $_COOKIE["numCount"]; ?> Quote Link to comment https://forums.phpfreaks.com/topic/157962-solved-f5-and-plus-1/#findComment-833153 Share on other sites More sharing options...
Psycho Posted May 13, 2009 Share Posted May 13, 2009 And, the reason your code didn't work is that you are using the name "numCounter" for the isset() test, but everywhere else you are using "numCount" Quote Link to comment https://forums.phpfreaks.com/topic/157962-solved-f5-and-plus-1/#findComment-833184 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.