How to kill a/all php sessions?

后端 未结 9 1220
暖寄归人
暖寄归人 2020-11-28 10:07

I have a very basic php session login script. I want to force logout of a certain user or force logout of all users.

How can I read all sessions made to my website,

9条回答
  •  再見小時候
    2020-11-28 10:45

    It depends on your session storage.

    If you're using PHP session storage, then they may be in the temporary directory of your server. Deleting the selected files will "kill" the session. However if your server is in running state, that session file may be occupied by HTTP process and you won't be able to delete it. Just look at the image below. File named as starting with "+~" are all session files.

    A nicer solution is to use a database session storage and delete the selected sessions from there. You can check out HTTP_Session2 which has multiple containers.

提交回复
热议问题