How do you destroy a particular or all Sessions?

How do you destroy a particular or all Sessions?

A session can be used to store information, which can then be used across various pages. The concept works similarly like a cookie; however, unlike a cookie, the information is not stored on the user’s computer, but rather on the server thus making the data safer.

A new session can be started by using the session_start() function. A variable can be registered into a session using the $_SESSION function.

Once the user logs out, the session is automatically closed. However, if the user wishes to remove a certain session data, it can be done so by using the unset $_SESSION function.

For Example:

// Removing session data





However, if the user wants to destroy a particular or all Sessions, it can be done so via the session_destroy() function.

// Destroying session



Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.