Home  >  Article  >  Backend Development  >  What is the method to destroy session in php

What is the method to destroy session in php

青灯夜游
青灯夜游Original
2021-07-15 11:55:293948browse

In PHP, you can use the session_destroy() function to destroy the session, the syntax format is "session_destroy()"; this function can destroy all the data in a session, that is, completely destroy the Session.

What is the method to destroy session in php

The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

If the entire Session ends, you can use session_destroy( ) function destroys all data of the current session, that is, completely destroys the Session. The syntax format of the function is as follows:

session_destroy()

session_destroy() function does not need to pass in any parameters. In addition, although the session_destroy() function can destroy the current session All data, but the $_SESSION array will not be reset, nor will the Cookie be reset. If the Session needs to be used again, the session_start() function must be called again.

Note: Using $_SESSION = array() to clear the $_SESSION array will also clear the contents of the Session file corresponding to this user on the server side. When using the session_destroy() function, the session file corresponding to this user on the server side is deleted.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What is the method to destroy session in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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