$pval) { if ((substr($pkey, 0, 4) === 'item') && ($pval !== '')) { $itemname[$i] = stripslashes($pval); $itemcheck[$i] = ($_POST['check' . substr($pkey, 4)] === 'ch'); if ($itemcheck[$i] && ($_POST['clearch'] === 'clearch')) { // Remove checked item $itemname[$i] = ''; $itemcheck[$i] = false; } else $i++; } } // Save cookie $cookie = sprintf('VtK%03d%02d', $width, $count); for ($i = 1; $i <= $count; $i++) { $cookie .= sprintf('%03d', strlen($itemname[$i])); $cookie .= $itemname[$i]; $cookie .= $itemcheck[$i] ? 'T' : 'F'; } setcookie('cxlist', $cookie, time() + 691200, '/check/', 'vidthekid.info', false); // <-- SITE-SPECIFIC INFO setcookie('cxlist', $cookie, time() + 691200, '/check/', 'vtk.dpksolutions.com', false); // <-- SITE-SPECIFIC INFO // $pagestate = 'Generated from POST data'; } elseif ($_POST['clearcookie']) { // Remove cookie button was clicked // Remove cookie $cookie = 'vtk'; // Not really removing the cookie per se, but making it look "bad" -- oh yeah and it expired 8 weeks ago, too setcookie('cxlist', $cookie, time() - 691200, '/check/', 'vidthekid.info', false); // <-- SITE-SPECIFIC INFO HERE TOO setcookie('cxlist', $cookie, time() - 691200, '/check/', 'vtk.dpksolutions.com', false); // <-- SITE-SPECIFIC INFO HERE TOO // Set default values $width = 40; $count = 25; // $pagestate = 'Default (cookie removed)'; } elseif ($_COOKIE['cxlist']) { // Cookie found // Set field variables from cookie $cookie = stripslashes($_COOKIE['cxlist']); if (substr($cookie, 0, 3) === 'VtK') { // Cookie is probably valid $width = (int)substr($cookie, 3, 3); $count = (int)substr($cookie, 6, 2); $strptr = 8; for ($i = 1; $i <= $count; $i++) { $namelen = (int)substr($cookie, $strptr, 3); $strptr += 3; $itemname[$i] = substr($cookie, $strptr, $namelen); $strptr += $namelen; $itemcheck[$i] = (substr($cookie, $strptr, 1) === 'T'); $strptr += 1; } } else { // Bad cookie // Set default values $width = 40; $count = 25; } // $pagestate = 'Generated from cookie data'; } else { // Page loaded with no post data or cookie // Set default values $width = 40; $count = 25; // $pagestate = 'Default'; } ?>
Use this checklist for groceries you need to pick up, tasks you need to accomplish, or any other checklist-type scenario. The information is saved as a cookie with your browser.