Delete a Cookie in PHP

Delete a cookie using the same path

Expire the cookie in the past and use the same path/domain scope used when it was created.

<?php
setcookie('Plus2netCookie', '', [
    'expires' => time() - 3600,
    'path' => '/',
    'secure' => true,
    'httponly' => true,
    'samesite' => 'Lax',
]);
?>
Cookie settings: Use Secure on HTTPS sites, HttpOnly when JavaScript does not need the cookie, and choose SameSite according to the cross-site behavior your application requires.
Cookie is removed. You can check this by going to Reading Cookies page to check.
setcookie('Plus2netCookie', '', ['expires' => time() - 3600, 'path' => '/', 'secure' => true, 'httponly' => true, 'samesite' => 'Lax']);
Here time() gives us the time elapsed in seconds between current time and Unix Epoch (January 1 1970 00:00:00 GMT). From this value we are subtracting 3600 seconds to give a past time as expire time for the cookie.



Subscribe to our YouTube Channel here



plus2net.com











PHP video Tutorials
✖
We use cookies to improve your browsing experience. . Learn more
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer