The PHP Function Session_Destroy
The php function session_destroy destroys the sessions holding files on the server.
A session in php is an information that is used by a webserver to keep track of when you start and finish visiting a website. The webserver stores the information about you in a temporary file and makes it available to all pages on the website until you close your browser. This gives the webserver the ability to know your username, password and other important information about you and use it whenever you visit the website.
When you visit a website, the first thing the webserver does is to create a unique session identification string called the PHPSESSID. This is sent to your browser in the form of a cookie and stored as a file on the webserver’s temporary directory with a name prefixed by sess_. When you come back to the same website, the PHP script can then identify that you are a visitor by comparing this unique session identification string with the one sent to your browser in the PHPSESSID cookie.
Creating a session is easy in php by calling the function session_start before any HTML is printed and then by assigning the session variables to the $_SESSION variable (which is an associative array). For example, to count how many times you have visited a particular website page, you might want to add a counter variable to the session.
When you call the session_destroy function, it does exactly what you expect it to do, it erases all of the session data from the $_SESSION variable and deletes the session holding file on the server. However, if you still have values in the $_SESSION array that you need to retain, you can pass in a new session id when calling the session_start function.