按ID结束会话。 [英] End sessions by id.

查看:62
本文介绍了按ID结束会话。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是PHP的新手,我正在构建一个PHP博客/用户系统的东西。它很好地融合在一起。现在我刚刚运行了用户系统。我正在使用会话代码表单这个啧啧。我发现当我从数据库中删除用户时,用户仍然登录。当我进一步开发时,肯定会引起问题。所以我想我可以将用户的最后一个会话ID存储在数据库中。然后当我运行删除时,用户还运行一个脚本,该脚本将以它的id结束会话。有没有办法做到这一点?我环顾四周但却找不到任何东西。

I am new to PHP and I am building a PHP blog/user system thing. It''s coming together pretty well. Right now I just got the user system running. Im using the session code form this tut. I found that when I delete a user from the database the user is still logged in. When I develop further it will cause problems for sure. So I was thinking I could store the users last session''s id in the db. And then when I run delete the user also run a script that would end a session by it''s id. Is there any way to do that? I looked around but couldn''t find any.

推荐答案

您是否仍然可以在线时删除用户?这有几种不同的方式。我不确定,但也许你可以像你说的那样做,并将会话ID存储在数据库中,可以通过session_id()调用然后清除,或者可能是session_destroy()的东西?


我认为你需要努力工作,如果你应该从你的数据库中删除,因为如果有人在使用你的系统,他们肯定希望他们能够控制它何时被删除?通过将它留在他们的手中,他们可以删除它,然后运行session_destroy()将它们记录下来。


我会为你寻找远程session_destroying。
Will you be deleting users often while they could still be online? THere are a few different ways. I am not sure, but maybe you can do as you say and store the session id in the database which can be recalled by session_id() and then cleared, or maybe something with session_destroy()?

I think you need to work hard at working out if you should be deleting from your database, because if someone is using your system, surely they want confidence that they have control on when it is deleted? By leaving it in their hands they can delete it and then run a session_destroy() to log them out.

I''ll have a look around for remote session_destroying for you.


我环顾四周但看不到任何东西。我在想这样的事情。


<?php

session_destroy(
I looked around but didn''t see anything. I was thinking something like this.

<?php
session_destroy(


sessionid);

?>
sessionid);
?>


这篇关于按ID结束会话。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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