Re: Re: Cookie Variables Maxing Out Using IE6

From: Date: Wed, 16 Aug 2006 16:37:12 +0000
Subject: Re: Re: Cookie Variables Maxing Out Using IE6
Groups: php.general 
Request: Send a blank email to php-general+get-240777@lists.php.net to get a copy of this message
>> 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>"; >> >> ?> Adam Zey Asked: > 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. Got it. Serialize works just fine. Thank you, Adam. David

« previous php.general (#240777) next »