Delete a cookie using php or jquery

Jul 10, 2014 | Blog | , ,

Using PHP

To remove a cookie in php we can use setcookie function

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

    To create a cookie which expires in 100 days

    $.cookie('name', 'value', { expires: 100 });

    To read a value


    To delete cookie


    NOTE: We cannot delete cookie of a different domain using any php or jquery. It is not allowed due to security issues.