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, ∼2154🔥, 0💬
Popular Posts:
How to access Query String parameters from "context.Request.Url.Que ry"object in Azure API Policy? Q...
How To Create an Array with a Sequence of Integers or Characters in PHP? The quickest way to create ...
How to reinstall npm with a node version manager? I am getting permission errors with the current ve...
Where to get a real Atom XML example? You can follow this tutorial to get a real Atom XML example: 1...
How to access URL template parameters from "context.Request.Matched Parameters"object in Azure API P...