亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Identifies user login status

A new status field is added to the think_user table in the database. After the user logs in, the database field is changed to indicate the login and online status.

After the user logs in successfully, add the following code:

微信圖片_20180307170227.png

Save the session and modify the members() method. The code is as follows:

<?php
Session::start();
if(isset($_SESSION['admin_name'])){
    //session存在不用驗(yàn)證權(quán)限
    $user = User::get([
        'user_name' => $_SESSION['admin_name']
    ]);
    //更改數(shù)據(jù)庫(kù)信息,登錄了就根據(jù)session把status改為1,退出或注銷就改為0
    Db::table('think_user')->where('user_name', $_SESSION['admin_name'])->update(['status' => 1]);
}

In this way, after the user logs in, the user will Modify the session value of the database and change the status to 1 to indicate that you have logged in


##Modify the front-end display code The user login status will be displayed:

<?php
{volist name="list" id="vo"}
<dt>
   <h3>{$vo.user_id} 姓名:{$vo.user_name}{if $vo.status==1}<span style="color: #008800">在線</span>{else}<span style="color: #880000">離線</span>{/if}</h3>
</dt>
{/volist}

Effect display:

gif5新文件 (13).gif

Database changes:

微信圖片_20180307171108.png

Continuing Learning
||
<?php echo "登錄狀態(tài)表示";
submitReset Code