Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2007
    Location
    N. Ireland
    Posts
    351
    Thanks
    16
    Thanked 4 Times in 4 Posts

    Cookies with PHP/JS

    If I create a cookie in JS can I remove it in PHP? If so, can someone tell me how?

    Thanks
    Daemonkin.
    If this was helpful, please add to my reputation
    Thousand Sons - Freelance Web Developer - ninetyonedegrees.com

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    echo the $_COOKIE global array to find out. To delete a cookie, use setcookie() with a time in the past.

    Example from the manual:
    PHP Code:
    <?php
    // set the expiration date to one hour ago
    setcookie ("TestCookie"""time() - 3600);
    setcookie ("TestCookie"""time() - 3600"/~rasmus/"".example.com"1);
    ?>
    Note from the manual:
    Cookies must be deleted with the same parameters as they were set with. If the value argument is an empty string, or FALSE, and all other arguments match a previous call to setcookie, then the cookie with the specified name will be deleted from the remote client.
    http://us2.php.net/manual/en/function.setcookie.php


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •