Using PHP
To remove a cookie in php we can use setcookie function unset($_COOKIE['amazon']); setcookie('amazon', null, -1, '/');where amazon is the name of the cookie.
- Second parameter must be set to blank or null
- Third parameter is expire date which should be set to a old or negative value.
- Fourth parameter is the path of the cookie.
Using Jquery
Use the library from
https://github.com/carhartl/jquery-cookie
To create a cookie which expires in 100 days
$.cookie('name', 'value', { expires: 100 });
To read a value
$.cookie('name');
To delete cookie
$.removeCookie('name');
NOTE: We cannot delete cookie of a different domain using any php or jquery. It is not allowed due to security issues.