What is the correct way to delete a cookie in PHP?
When you want to delete a cookie in PHP, you need to set the cookie's expiration time to a past time, which effectively removes the cookie from the browser. This can be done by using the setcookie() function with a past expiration time.
// Delete a cookie by setting its expiration time to a past time
setcookie("cookie_name", "", time() - 3600, "/");
Related Questions
- What are common pitfalls when using PHP for user registration and email functionalities in a forum setting?
- How can PHP be used to handle multiple input fields with corresponding comments for database insertion efficiently?
- How can PHP developers effectively handle complex data structures like 0_1_0 in MySQL queries?