如何从管理面板销毁特定用户的会话数据 [英] How to destroy a specific user's session data from an admin panel

查看:117
本文介绍了如何从管理面板销毁特定用户的会话数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个登录系统,而不使用任何框架。

I am creating a login system, without the use of any frameworks.

管理员可以访问一个页面,其中所有用户都以表格形式列出。
我在名为注销用户的每个用户的列中都有一个按钮。
如果I /管理员按下按钮,则系统/ Web服务器应销毁目标用户I /管理员的会话。
当目标用户刷新其页面时,我将不再登录。

The admin can access a page where all the users are listed in a table form. I have a button in a column for every user named "Sign out user". If I/The admin press the button,the system/web server should destroy the session of the user I/The admin targeted. When the targeted user refreshes his page, I wouldn't be logged in anymore.

注意:
我已经将session_id存储在当前用户的数据库中。

Notes: I am already storing the session_id in the database for the current user.

推荐答案

由于具有会话ID,因此可以很容易地劫持该会话,然后销毁它。只需从服务器获取会话ID并将其传递给此函数即可。

You can very easily hijack that session and then destroy it since you have the session id. Simply get the session id from the server and pass it this function.

function destroy_third_party_session($in_session_id){
  session_id($in_session_id); // Sets the session id;
  session_start(); // starts the session as that session id
  session_destroy(); // destroy the session
  session_commit();
}

这篇关于如何从管理面板销毁特定用户的会话数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆