SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Mar 2011
    Location
    Manchester, UK
    Posts
    226
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cookie Keeps Expiring When It Shouldnt

    Hi Guys,

    I'm trying to set a cookie but it keeps expiring as soon as its made and i cant work out why. Below is my code:

    PHP Code:
    //set new cookie signup
                
    $expire=time()+60*60*24*30;
                
    $parts explode("."$_SERVER["HTTP_HOST"]);
                
    $parts_size sizeof($parts);
                
    $domain "." $parts[$parts_size 3] . "." $parts[$parts_size 2] . "." $parts[$parts_size 1];
                
    setcookie("site_reg""$leadid"$expire"/"$domain); 
    As you can see the cookie should last for 30 days and only expire once it has gone past the 30 days. But for some reason it expires right away. I'm using HTTPFOX (FireFox Addon) which is showing me debug and cookie information and can see the expiry of the cookie is the same time the cookie is made. Any help would be great.

    Thank you!
    You're Help Does Not Go Unnoticed, I have So Far Donated 25 GBP
    To Cancer Research UK As A Thank You To All The SitePoint
    Members That Have Helped Me In The PHP Forum Thank You!

  2. #2
    Non-Member Max Height's Avatar
    Join Date
    Dec 2011
    Posts
    303
    Mentioned
    6 Post(s)
    Tagged
    1 Thread(s)
    1) What is the value of $domain when you echo it?

    2) I assume you are aware that cookies created by php will become available only after the page is reloaded.

  3. #3
    Non-Member Max Height's Avatar
    Join Date
    Dec 2011
    Posts
    303
    Mentioned
    6 Post(s)
    Tagged
    1 Thread(s)
    and

    3) I assume cookies are enabled in your browser

    Edit:

    the 30 mins edit time on my previous post has expired


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
  •