Fail store object in cookie
Posted: Mon May 31, 2010 10:55 am
Hi all, I have a question about object that stored in cookie. The following is the example that I want to do:
a.php
b.php
I want to stored a object in cookie in a.php, and show the object in b.php. It is success when I done in my PC, but when I upload to web hosting, it fail. Can anyone help me? Is that any problem(s) that I write? And can anyone tell me how to fix it? Thank you very much!!
a.php
Code: Select all
<?
class a
{ public $a;
function __construct($a)
{ $this->a=$a;
}
}
$A=new a("kk");
setcookie("A",serialize($A));
?>
Code: Select all
<?
class a
{ public $a;
function __construct($a)
{ $this->a=$a;
}
}
$A=unserialize($_COOKIE['A']);
echo $A->a;
?>