retrieve cookie value in cakephp -
i'm storing multidimensional array in cookie.
$this->cookie->write('cart', $products, false, 3600 );
below multidimensional array i'm storing in cookie
array ( [cart] => array ( [user_id] => [product_id] => 92 [quantity] => 1 [date_created] => [date_modified] => [product_name] => shoes [price] => 12 ) )
but when read cookie, gives me output
[{\"cart\":{\"user_id\":\"\",\"product_id\":\"7\",\"quantity\":\"1\",\"date_created\":\"\",\"date_modified\":\"\",\"product_name\":\"iphone\",\"price\":\"12\"}}]
below code i'm using read cookie
$this->cookie->read('cart');
on local server works alright gives me above mentioned output when seek on online server
you seek next write
$this->cookie->write('cart', serialize($products), false, 3600);
and read
unserialize($this->cookie->read('cart'));
your cookie beingness saved plain text.
cookies cakephp-2.0
No comments:
Post a Comment