SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Santos L Halper Zenith's Avatar
    Join Date
    May 2002
    Location
    Finland
    Posts
    641
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cookie value problem with IE - all other browsers ok

    Veri irritating and difficult problem with cookies and IE (5 & 6), maybe someone could give a hint what's wrong. We have a frameset (navigation + banner + footer + main frame, basic stuff), and cookies are set on the main frame's <body OnUnload> event. When i click a link on the navigation the page on the main frame gets unloaded and cookie is set, and then i want to do stuff with that cookie on the next page.

    Very simple, but problem is this: if I use IE i have to click the navigation link 2 times (= to load the new page twice) to make it work. And sometimes the values are not shown on the new page even though the cookie is always set properly. I have an alert box on the JS function which is driven correctly on onload and the values seem correct. Basically with IE this cookie stuff works without any sense and logic.

    The js code:
    There are other non-cookie related stuff in this function, but this is the row where cookies are set:

    document.cookie="something=" + variable_x + ";expiration=" + get_expir() + ";path=/somefolder";

    and
    function get_expir() {
    var aika = new Date();
    // 365 * 24 * 60 * 60 * 1000ms = 31536000000ms
    aika.setTime(aika.getTime() - 31536000000);
    //i changed this to minus 3153... etc to test the expiration
    return aika.toGMTString();
    }

    With Mozilla and Opera no problems, everything works perfectly. But with IE the problem I described. And of course deadline is closing fast... and I'm about to lose my mind.

    -Z-

  2. #2
    Santos L Halper Zenith's Avatar
    Join Date
    May 2002
    Location
    Finland
    Posts
    641
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alright never mind, problem solved. Just in case someone else has the same problem one day:

    I have a frameset like this:

    Code:
     ---------------------------------------------
    | header
    
     ---------------------------------------------
    |menu |		  main
     ---------------------------------------------
    |bottom												   
    
     ---------------------------------------------
    There are checkboxes on the main page. User selects few of them and then clicks something from the menu and goes to another page. When I print the cookie on the main page it prints nothing. When I click the link again and load the main page cookies exist. Again, a link click: no cookies. Another link click: cookies exist. I tried to remove the cache, add querystring parameters but nothing worked. Then I realized it all works fine if I only reload the main frame. So, I added a querystring parameter to the menulink and put a PHP code to the very first row of the main page:

    Code:
    <?php
     
    if(isset($_GET['foobar'])) {
    header("location:this_same_page.php");
    exit;
    }
    ?>
    Now when I click a link from the menu it kind of reloads the page again and no problems exist. And after the reload the foobar querystring parameter no longer exists --> no continuous reloading. And because the page is not fully loaded before that PHP code user won't even notice the action.

    -Z-
    Last edited by Zenith; Oct 8, 2003 at 04:46.


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
  •