Level 23
@masandikdev you return a mixed value, which can be an array or int. so you have to check if the value from the cookie is an array or int.
quick and dirty:
public function sample2($id)
{
if ($cookie_data = Cookie::get('name')) {
if(!is_array($cookie_data))
{
$data = [];
$data[] = $cookie_data;
}else{
$data = $cookie_data;
}
array_push($data, $id);
} else {
$data = $id;
}