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, 1418🔥, 0💬
Popular Posts:
Where to get the detailed description of the json_encode() Function in PHP? Here is the detailed des...
How To Move Uploaded Files To Permanent Directory in PHP? PHP stores uploaded files in a temporary d...
How to decode the id_token value received from Google OpenID Connect authentication response? Accord...
How to create a navigation file like navigation.xhtml for an EPUB 3.0 book? At least one navigation ...
Where to find tutorials on RSS specifications? I want to learn it to describe my API services. Here ...