Re: Cookie Variables Maxing Out Using IE6

From: Date: Wed, 16 Aug 2006 15:40:07 +0000
Subject: Re: Cookie Variables Maxing Out Using IE6
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-240774@lists.php.net to get a copy of this message
dpgirago@mdanderson.org wrote:
Does IE6 limit somehow/somewhere the number of cookie variables I can create and store? The following code snippet successfully creates 24 cookie variables when run in FireFox, but in IE6 it is limited to 20. I can provide the full code with HTML/Javascript if anyone wants to test for themselves. David <?php // populates a hidden form variable on the second submit $somevar = "anything"; if (!IsSet($_POST['monitors']) || empty($_POST['monitors'])) {
    $_POST['monitors'] = array();
} /*********** Manage Monitor CheckBoxes via $_POST & $_Cookie *************/ // code in here only runs the first time the page is displayed if ($_POST['trakVisit'] == "") {
      if (IsSet($_COOKIE['cookieMeter'])) {
            foreach ($_COOKIE['cookieMeter'] as $key => $value) {
                  if ($value == 'CHECKED') {
                        $checked[$key] = 'CHECKED';
                  }
                  else
                        $checked[$key] = "";
            }
      }
} // runs on the second and subsequent submits elseif ($_POST['trakVisit'] == "anything") {
      for ($i=1; $i <= 24; $i++) {
            if (in_array($i, $_POST['monitors'])) {
                  setcookie("cookieMeter[$i]", 'CHECKED', time()
+60*60*24*12, '/', ".mydomain.com", 1);
                  $checked[$i] = 'CHECKED';
            }
            elseif(!in_array($i, $_POST['monitors'])) {
                  $checked[$i] = '';
                  setcookie("cookieMeter[$i]", 'CHECKED', time()-3600, '/',
".mydomain.com", 1);
            }
      }
} echo "<pre>"; print_r($_COOKIE); echo "</pre>"; ?>
Why do you need more than one single cookie? If you want to store multiple pieces of information, serialize the data or something similar. Regards, Adam Zey.

« previous php.general (#240774) next »