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, ∼2501🔥, 0💬
Popular Posts:
Where to find tutorials on Python programming language? I want to learn Python. Here is a large coll...
How to build a test service operation to dump everything from the "context.Request" object in the re...
Why I am getting "LNK1104: cannot open file 'MSCOREE.lib'" error when building a C++/CLI program? Vi...
Why am I getting this "Docker failed to initialize" error? After installing the latest version of Do...
What is EPUB 3.0 Metadata "dc:description" Element? EPUB 3.0 Metadata "dc:description" is an optiona...