una roba così che dici?
<?php
class Cookie
{
public $name;
public $value;
public $expire;
public $path;
public $domain;
public $secure;
public $httponly;
public function Cookie($n, $v = "", $e = 0, $p = NULL, $d = NULL, $s = false, $h = false)
{
$this->name = $n;
$this->value = $v;
$this->expire = ($e == 0) ? $e : (int) ($e * 60 * 60) + time();
$this->path = ($p == NULL) ? Cookie::getPath() : $p;
$this->domain = $d;
$this->secure = $s;
$this->httponly = $h;
}
public function setcookie($save_all = false)
{
$cookie = ($save_all) ? serialize($this) : $this->value;
$_COOKIE[$this->name] = $cookie;
setcookie($this->name, $cookie, $this->expire, $this->path,
$this->domain, $this->secure, $this->httponly);
}
static public function getPath()
{
$cartelle = explode("/", $_SERVER["PHP_SELF"]);
$path = "";
$dimensione = count($cartelle) - 1;
for ($i = 0; $i < $dimensione; $i )
$path .= $cartelle[$i] . "/";
return $path;
}
static public function unserialize($nomeCookie)
{
$cookie = unserialize(stripslashes($_COOKIE[$nomeCookie]));
if ($cookie instanceof Cookie)
return $cookie;
else
throw new Exception("Cookie corrotto");
}
static public function cancel($nomeCookie)
{
unset($_COOKIE[$nomeCookie]);
setcookie($nomeCookie, "", time() - 86400); // Imposta la scadenza al giorno prima
}
public function __toString()
{
return $this->value;
}
}
?>
_