I am using Cakephp 3.0.I am new in cookie concept. I have successfully created a cookie but i want to delete a value from cookie array. Here is my code:-
enter code here
$cookiedata=
Array
(
[0] => 2
[1] => 1
)
$_GET['id'] = 2;
public function cartitems(){
$cookiedata = $this->Cookie->read('ProductCartdata');
$this->loadModel('Products');
$query = $this->Products->find('all')->where(['id IN' =>$cookiedata]);
$products = $query->hydrate(false)->toArray();
if(isset($_GET['id'])){
if(($key = array_search($_GET['id'], $cookiedata)) !== false) {
unset($cookiedata[$key]);
}
$this->redirect(['controller'=>'test','action' => 'cartitems']);
}
$this->set(compact('products','cookiedata'));
}
And i want that result:-
enter code here
Array
(
[0]=>1
)