<?
class SiteCookie {
var $name='akashaID';
var $val=array();
var $dir='/'; // all dirs
var $site='';
function SiteCookie($cname, $cexpires="", $cdir=""){
GLOBAL $$cname
$this->name=$cname;
if($cexpires) $this->expires=$cexpires;
if($cdir) $this->dir=$cdir;
@parse_str($$cname);
@parse_str(str_replace("GLOBALS[", "val[", $$cname));
$this->val=$val;
}
function put($var, $value){
GLOBAL $$var;
$$var=$value;
$this->val["$var"]=$value;
}
function set(){
if(is_array($this->val)){
reset($this->val);
$cnt=count($this->val);
$curr=current($this->val);
$cookie_val='';
for($x=0;$x<$cnt;$x++){
$key=key($this->val);
$cookie_val.="GLOBALS[$key]=$curr";
$curr=next($this->val);
if($curr) $cookie_val.='&';
}
}
setcookie("$this->name", $cookie_val, time()+ 12000, $this->dir, $this->site);
}
}
?>