Get the App
SLTechnology News&Howtos  ›  Development  › 

How to solve the problem of php failed to clear cookie

Shulou Source: shulou.com Published: 2022-06-02 14:53:17 09月10日 Update

This article focuses on "how to solve the problem of php clearing cookie failure", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to solve the problem of php clearing cookie failure".

Php failed to clear cookie because the path parameter of cookie does not correspond to each other. The solution is to change the deletion code to "setcookie ($key,", time ()-36000).

This article operating environment: windows7 system, PHP7.1 version, DELL G3 computer

What if php fails to clear cookie?

Reason why php cookie cannot be deleted

Cookie can be deleted through setcookie (name, value, expiration, path, host, secure, httponly)

If the cookie name is guaranteed to be the same and cannot be deleted, it means that the path parameter of cookie does not correspond to the result.

For example, if you are setting up cookie, this is it.

Setcookie ($key,$value,time () + 36000 fuzz')

Then when deleting, it must be like this.

Setcookie ($key, "", time ()-36000 jigsaw marks')

The slash after it means path, which must be consistent.

At this point, I believe you have a deeper understanding of "how to solve the problem of php clearing cookie failure". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Problem content parameter learning practical deeper same consistent code interest method reason name practicality practice what to do situation simple operation slash method Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Huawei Apple macOS Shulou Information