Implementation of user logout function

Add the following code in application/index/view/login/members.html:

<form action="/public/index.php/index/login/logout" method="post">
   <p><input style="border: #008800" type="submit" value="注销"></p>
</form>

Add the method logout() in application/index/controller/Login.php

Code:

<?php
public function logout(){
    session_start();
    Db::table('think_user')->where('user_name', $_SESSION['admin_name'])->update(['status' => 0]);
    session_unset($_SESSION['admin_name']);
    session_destroy();//销毁一个会话中的全部数据
    return $this->error('注销成功','index');
}

Logout requires deleting the session and modifying the database status information

The running results are as follows Shown:
gif5新文件 (14).gif

Continuing Learning
||
<?php echo "注销功能";
submitReset Code