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 7 of 7
  1. #1
    Regular Coder
    Join Date
    Sep 2004
    Posts
    230
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Cookie clears in FF but not IE

    cookies.js
    Code:
    function Get_Cookie(name) {
       var start = document.cookie.indexOf(name+"=");
       var len = start+name.length+1;
       if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
       if (start == -1) return null;
       var end = document.cookie.indexOf(";",len);
       if (end == -1) end = document.cookie.length;
       return unescape(document.cookie.substring(len,end));
    }
    function Set_Cookie(name,value,expires,path,domain,secure) {
        var cookieString = name + "=" +escape(value) +
           ( (expires) ? ";expires=" + expires.toGMTString() : "") +
           ( (path) ? ";path=" + path : "") +
           ( (domain) ? ";domain=" + domain : "") +
           ( (secure) ? ";secure" : "");
        document.cookie = cookieString;
    } 
    function Delete_Cookie(name,path,domain) {
       if (Get_Cookie(name)) document.cookie = name + "=" +
          ( (path) ? ";path=" + path : "") +
          ( (domain) ? ";domain=" + domain : "") +
          ";expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
    how its inserted:
    Code:
    <script language="javascript" type="text/javascript" src="js/cookies.js"></script>
    the actual call:
    Code:
    <a onclick="Delete_Cookie('weatherZIP','/','.mydomain.com');" href="" >Change Location</a>
    how its set [in php]
    PHP Code:
    setcookie("weatherZIP",$_POST['zipcode'],time() + 100000,"/",".mydomain.com"); 

    now, that works like a charm in FF... but in IE it does nothing
    Last edited by scrupul0us; 02-23-2007 at 04:43 AM.
    IF I DID GOOD THROW ME A REP POINT

  • #2
    Regular Coder
    Join Date
    Sep 2004
    Posts
    230
    Thanks
    1
    Thanked 0 Times in 0 Posts
    ideas?
    IF I DID GOOD THROW ME A REP POINT

  • #3
    Regular Coder
    Join Date
    May 2004
    Location
    Alabama, USA
    Posts
    237
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Are you sure your 'expires' date/time format is correct?

    Try this:
    Code:
    new Date(0).toGMTString()

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Not sure but try this:
    Code:
    <a onclick="Delete_Cookie('weatherZIP','/','.mydomain.com');return false;" href="#">Change Location</a>
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #5
    Regular Coder
    Join Date
    Sep 2004
    Posts
    230
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by MikeFoster View Post
    Are you sure your 'expires' date/time format is correct?

    Try this:
    Code:
    new Date(0).toGMTString()
    so instead of: expires.toGMTString()
    do: new Date(0).toGMTString()

    or do you mean:

    instead of: ";expires=Thu, 01-Jan-70 00:00:01 GMT"
    do: ";expires="+new Date(0).toGMTString();
    Last edited by scrupul0us; 02-24-2007 at 01:37 AM.
    IF I DID GOOD THROW ME A REP POINT

  • #6
    Regular Coder
    Join Date
    Sep 2004
    Posts
    230
    Thanks
    1
    Thanked 0 Times in 0 Posts
    i actually managed to re-write the code in PHP and now it works great in both IE and FF
    IF I DID GOOD THROW ME A REP POINT

  • #7
    Regular Coder
    Join Date
    May 2004
    Location
    Alabama, USA
    Posts
    237
    Thanks
    0
    Thanked 0 Times in 0 Posts


  •  

    Posting Permissions

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