User exits logout operation
For logged-in users, the interface is as follows:
Click logout to destroy the session and clear the session. content, destroy all data in a session, and destroy the connection between PHPSESSID and cookies. The successful operation interface is as follows:
##The code is as follows:
logout.php
<?php /** * Created by PhpStorm. * User: Administrator * Date: 2018/2/27 0027 * Time: 上午 11:44 */ header('Content-type:text/html;charset=utf-8'); session_start(); if(isset($_SESSION['username'])){ // var_dump(session_name());die(); session_unset($_SESSION['username']); session_destroy();//銷毀一個會話中的全部數(shù)據(jù) setcookie(session_name(),'');//銷毀與客戶端的聯(lián)系 echo "<script>alert('注銷成功!');location.href='login.html';</script>"; }else{ echo "<script>alert('注銷失?。?#39;);</script>"; }