Hi,

I get an error when i try to echo my cookie. Notice: unserialize() [function.unserialize]: Error at offset 0 of 12 bytes in... I cannot find a solution. Help please.

Thanks

class MyCookie {
  public function __construct($cookieName, $sessionId) {
    if(! isset($_COOKIE[$cookieName])) {
      $cookieValue["SESSION"] = $sessionId;
      setcookie($cookieName, $cookieValue, time()+60*60*24*7);
    }
  }
  public function fetchMe($cookieName) {
     $value = unserialize(stripslashes($cookieName));
     echo "<pre>";
     print_r($value);
  }
}

$mycookieObj=new MyCookie("myname", "testtest123");
$mycookieObj->fetchMe("myname");

Yes it must have been.

$value = unserialize(stripslashes($_COOKIE[$cookieName]));

solved

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.