variables_send, array('variable' => $variable, 'data' => $data)); } // Send the response function send() { // Make sure the pages are not cached header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); // IE wants a privacy policy.. so send it one that will make it accept our cookies header('P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"'); // 60 seconds in the future is sufficient time for the browser to receive the cookie // and deal with it // 60 seconds is NOT sufficient, and clocks being off screw the whole world up. Deal... $time = time() + 3800; // Loop through the variable output buffer foreach ($this->variables_send as $key => $val) { // Send the variables across in the form of cookies $domain = ''; if (isset($this->vars['domain'])) { $local = explode('.', $_SERVER['HTTP_HOST']); $foreign = explode('.', addslashes(urldecode($this->vars['domain']))); for ($i = count($foreign)-1; $i >= 0; $i--) { if (isset($local[$i])) { if ($foreign[$i] == $local[$i]) { $domain = '.'.$foreign[$i].$domain; } else { $i = -1; } } else { $i = -1; } } } if (strlen($domain) > 0) { $domain = substr($domain, 1); } setcookie('aardvark_'.$this->variables_send[$key]['variable'], $this->variables_send[$key]['data'], $time, '/', $domain); } // XMLHttpRequest fails if it doesnt receive any 'body' content so send some of // that as well as the headers. echo(''); } // Grab incoming variables and sort them out into easy to read global variables function receive() { $this->variables_receive = array(); foreach ($_GET as $key => $val) { if (substr($key, 0, 9) == 'aardvark_') { $variable = addslashes(substr($key, 9)); $data = addslashes($val); array_push($this->variables_receive, array('variable' => $variable)); array_push($this->variables_receive, array('data' => $data)); $this->vars[$variable] = $data; } } return $this->variables_receive; } } ?>