Jump to content

Trying to increment a cookie value


stevemacdonald99

Recommended Posts

PHP newbie. Apologies if this has been answered elsewhere. I have Firefox 3.5.3. I use the following code, from the file test2.php to create, and attempt to increment the cookie, 'centon'. It will create the cookie, but never increment it-it is always zero. Any ideas?

THANKS!!!!!!

 

<?php

 

//check if the $count variable has been associated with the count cookie

if (!isset($centon)) {

 

    $centon = 2;

} else {

    $centon++;

}

    if (!setcookie("centon", $centon, time()+600, "/", "", 0)) {

      echo("<p>bad assignment</p>");

    }

?>

<html>

    <head>

        <title>Session Handling Using Cookies</title>

    </head>

    <body>

        This page has been displayed: <?=$centon ?> times.

    </body>

</html>

 

 

Link to comment
https://forums.phpfreaks.com/topic/176093-trying-to-increment-a-cookie-value/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.