SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: Cookie help

  1. #1
    SitePoint Evangelist jimday1982's Avatar
    Join Date
    Sep 2002
    Location
    Atlanta, GA
    Posts
    562
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cookie help

    I'm having trouble figuring out how to determine if a cookie is expired or not...I curently have:

    PHP Code:
    <?php
    setcookie
    ("popup""nopopup"time()+36000);
    ?>
    Basically, I want to add to that:

    If cookie is expired, $showpopup = "true"
    else, $showpopup = "false"

    Your help is appreciated.
    Jimmy Day
    Senior Systems Analyst
    Piedmont Healthcare Corporation

  2. #2
    SitePoint Addict say's Avatar
    Join Date
    Sep 2003
    Location
    At work
    Posts
    371
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    after setting cookie (with the expiration time), you can just simply do a check:

    PHP Code:
    if(!isset($_COOKIE['popup']) {
       
    // do stuff


  3. #3
    SitePoint Evangelist jimday1982's Avatar
    Join Date
    Sep 2002
    Location
    Atlanta, GA
    Posts
    562
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is something wrong with this code:

    PHP Code:
    <?php
    if(!isset($_COOKIE['popup2']) { 
    $showpopup "True";
    setcookie("popup2""nopopup"time()+36000);
    }
    ?>
    I'm getting a Parse error: parse error, unexpected '{' in /home/day1982/public_html/index.php on line 2..
    Jimmy Day
    Senior Systems Analyst
    Piedmont Healthcare Corporation

  4. #4
    SitePoint Wizard mark_W's Avatar
    Join Date
    Mar 2004
    Location
    West Midlands, United Kingdom
    Posts
    2,631
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are missing a ) before your {

  5. #5
    SitePoint Evangelist jimday1982's Avatar
    Join Date
    Sep 2002
    Location
    Atlanta, GA
    Posts
    562
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks - got it working
    Jimmy Day
    Senior Systems Analyst
    Piedmont Healthcare Corporation


Bookmarks

Posting Permissions

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