A good logout script is needed in most applications, and here’s the one I use. I have this script in a ‘config’ file that I call at the beginning of every file in the site, so you can logout from any page…
if(isset($_GET['logout'])){ // trigger if ?logout is in the url $_SESSION = array(); if(isset($_COOKIE[session_name()])){ setcookie(session_name(), '', time()-42000, '/'); } session_destroy(); header ('location: /'); // redirect to root exit(); }
To trigger it, simply add ‘?logout‘ after a url path, i.e. www.mydomain.com/?logout.
Main Category
Secondary Categories