php cookie variables

Discussion in 'PHP' started by coykiesaol, May 20, 2011.

  1. #1
    I was wondering how to set and retrieve information from a cookie, where the information retrieved will be modified by a variable, for example if the cookie is 1, i want the next cookie to be 2, so can I add "+1"?

    For example:

    <?php
    setcookie("count","1");
    ?>

    and when the cookie is read I want to do like this:
    <?php
    if (isset($_COOKIE["count"]))
    echo "new number" . $_COOKIE["count"]+1 . "!<br />";
    else
    echo "no numbers to add!<br />";
    ?>
     
    coykiesaol, May 20, 2011 IP
  2. KastorPM

    KastorPM Peon

    Messages:
    11
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    if (isset($_COOKIE["count"])) {
    $_COOKIE["count"]++;
    }
     
    KastorPM, May 20, 2011 IP