dongsi073898 2012-11-16 19:33
浏览 40

如果会话存储在默认的php会话存储中,是否可以删除/管理用户的会话?

Are there any ways to drop user sessions when sessions are stored in default php session storage?

For example, I'm website admin and I want to ban logged user. User authentification status is stored in session. I'm deleting user row from database, but user is still logged and all nessesary authentification information is also stored in session. I need to drop/modify session.

Possible ways:

  • load user's row from DB on every request
  • create file, saying to delete user's session and check this file existence on every request
  • crete file in /dev/shm (very fast checking), but file will be removed when rebooted
  • store sessions in DB (overhead for my project)
  • store sessions in nosql (redis, memcachedb) (overhead for my project)

Any elegant ways except storing user's sessions in database or nosql data storages?

  • 写回答

1条回答 默认 最新

  • douchenchepan6465 2012-11-16 19:40
    关注

    The only way I know how to do this is to delete the session record. If it's a file, delete the session file. If session is stored in a DB or memcache delete it there. The tough question is how to find the session id and if one even exists for a user.

    If it's a file an you store the email or user id in it, you could look for that file. Session storage in DB should be easy to query. Not sure how you'd do it in memcache.

    If you don't regenerate sessions on each request, you could always set the session_id on session creation to something unique to a user--be careful if you don't use SSL you might open a way to hijack sessions if the unique key you use is easy to guess (like a user_id). You could then store the users session id once in the DB with the user record when they log in.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog