setting and deleting cookies

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • laredotornado@zipmail.com

    #1

    setting and deleting cookies

    Hi,

    I'm using PHP 4.4.4 on Fedora Core 5 Linux. Two questions, if I
    create a cookie under the "/" path ...

    setcookie('Logg edIn', 1, time() + REMEMBER_ME_TIM E, "/");

    1. How do I check if this cookie is set at the top of a given PHP
    page?

    2. How do I delete this cookie?

    Thanks for your help, - Dave

  • Good Man

    #2
    Re: setting and deleting cookies

    "laredotornado@ zipmail.com" <laredotornado@ zipmail.comwrot e in
    news:1182199107 .639768.126530@ i13g2000prf.goo glegroups.com:
    setcookie('Logg edIn', 1, time() + REMEMBER_ME_TIM E, "/");
    >
    1. How do I check if this cookie is set at the top of a given PHP
    page?
    Go to the next page and try to echo it... yes, the NEXT page:

    <?php
    $LoggedInCookie = $_COOKIE['LoggedIn'];
    echo $LoggedInCookie ;
    ?>

    2. How do I delete this cookie?
    set it again with negative time:

    setcookie("Logg edIn", '', time()-42000, '/'); //erase the cookie


    good luck!

    Comment

    • Toby A Inkster

      #3
      Re: setting and deleting cookies

      laredotornado@z ipmail.com wrote:
      setcookie('Logg edIn', 1, time() + REMEMBER_ME_TIM E, "/");
      >
      1. How do I check if this cookie is set at the top of a given PHP
      page?
      if (isset($_COOKIE['LoggedIn']))
      echo "Cookie is set.";
      2. How do I delete this cookie?
      Re-set the cookie, using a time in the past.

      setcookie('Logg edIn', 0, 0, "/");

      By the way, if this is for a log in system, it's hideously insecure. Users
      can easily tamper with cookies. Use sessions instead.

      --
      Toby A Inkster BSc (Hons) ARCS
      [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
      [OS: Linux 2.6.12-12mdksmp, up 115 days, 5:09.]

      dict, thes & ency

      Comment

      Working...