php - cakephp : cookies not create after deleted -
i have question cookies in cakephp. create cookies in cakephp view successfully, , wrote javascript function delete cookies if page reloads, , function deleted.
after cookies deleted, same cookies cannot create anymore. why happen?
this code have used create cookies :
$isicookies=$awb['awb']['id'].'^'.$awb['awb']['awb_number'].'^'.$companies[$awb['contract']['company_id']].'^'.$awb['address']['address'].'^'.$types[$awb['contractdetail']['content_type_id']].'^'.$awb['awb']['colie'].'^'.$kilo.'^'.$manifestdetails[$awb['awb']['id']]; if(!isset($_cookie['manifest_courier'])) { setcookie("manifest_courier", $isicookies, $date_of_expiry, "/"); } else { setcookie("manifest_courier", rawurldecode($_cookie['manifest_courier']).'*'.$isicookies, $date_of_expiry, "/" ); }
and javascript function have used deleted cookies :
$(window).unload(function() { cookies.erase('manifest_courier'); });
please tell me why cookies not created if page reload. help.
you don't need in views. first off, make sure cookie component included in controller.
var $components = array('cookie');
then, in function,
$isicookies = $awb['awb']['id'].'^'.$awb['awb']['awb_number'].'^'.$companies[$awb['contract']['company_id']].'^'.$awb['address']['address'].'^'.$types[$awb['contractdetail']['content_type_id']].'^'.$awb['awb']['colie'].'^'.$kilo.'^'.$manifestdetails[$awb['awb']['id']]; if($this->session->check('manifest_courier')) { $this->cookie->write('manifest_courier',$isicookies,false,$date_of_expiry); }else{ $this->cookie->write('manifest_courier',rawurldecode($_cookie['manifest_courier']).'*'.$isicookies,false,$date_of_expiry); }
in view, use js delete cookie if still exists after refresh.
Comments
Post a Comment