Home > Backend Development > PHP Problem > How to clear cookies in browser in php

How to clear cookies in browser in php

王林
Release: 2023-03-04 19:04:01
Original
2526 people have browsed it

php method to clear cookies in the browser: You can use the setcookie() function to set the cookie expiration time to achieve the purpose of clearing cookies. The setcookie() function is used to send an HTTP cookie to the client.

How to clear cookies in browser in php

# The setcookie() function sends an HTTP cookie to the client.

(Recommended tutorial: php graphic tutorial)

The cookie must be assigned before any other output is sent to the client. If successful, the function returns TRUE. Returns FALSE on failure.

Syntax:

setcookie(name,value,expire,path,domain,secure)
Copy after login

Parameters:

  • ##name Required. Specifies the name of the cookie.

  • #value Required. Specifies the cookie value.

  • #expire Optional. Specifies the cookie expiration time.

  • path Optional. Specifies the server path for cookies.

  • domain Optional. Specifies the domain name for the cookie.

  • secure Optional. Specifies whether cookies need to be transmitted over a secure HTTPS connection. Set to TRUE if the cookie needs to be transmitted over a secure HTTPS connection. Default is FALSE.

(Learning video recommendation:

php video tutorial)

Implementation code:

//将过期时间设为一小时前
setcookie("TestCookie", "", time() - 3600);
Copy after login

The above is the detailed content of How to clear cookies in browser in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template