Tools, FAQ, Tutorials:
Closing a Session Properly in PHP
How To Close a Session Properly in PHP?
✍: FYIcenter.com
Let's say you site requires users to login. When a logged in user clicks the logout button, you need to close the session associated with this user properly in 3 steps:
Below is a good sample script:
<?php
session_start();
$_SESSION = array();
if (isset($_COOKIE[session_name()])) {
setcookie(session_name(), '', time()-42000, '/');
}
session_destroy();
print("<html><pre>");
print("Thank you for visiting FYICenter.com.\n");
print(" <a href=login.php>Login Again.</a>\n");
print("</pre></html>\n");
?>
⇒ What Is session_register() in PHP
⇐ Determining If a Session Is New in PHP
2016-10-22, ∼1968🔥, 0💬
Popular Posts:
Where to find EPUB Sample Files? Here is a list of EPUB sample files collected by FYIcenter.com team...
How to use the "@(...)" expression in Azure API Policy? The "@(...)" expression in Azure API Policy ...
How to detect errors occurred in the json_decode() call? You can use the following two functions to ...
Can Multiple Paragraphs Be Included in a List Item? Yes. You can include multiple paragraphs in a si...
How to read RSS validation errors at w3.org? If your RSS feed has errors, the RSS validator at w3.or...