How to destroy a specific PHP session

前端 未结 3 1005
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-06 14:53

I am looking for insights into how to destroy a specific session in PHP. Through a partner website a user logs into the main website using a token and obtains a full session

3条回答
  •  一个人的身影
    2021-01-06 15:22

    If you wish to be able to 'kick' the sessions of a user(s), the only way you can do it is if you use MySQL (or someother db, sqlite even) for your session storage.

    Then you can simply remove entries from the db to kill a session.

    This also allows you do do things such as, 'take control' of a specific user's session and other stuff :)

    See this for a very basic run through: http://www.devshed.com/c/a/MySQL/Custom-Session-Management-Using-PHP-and-MySQL/ (not the best example but good enough full example to start you).

    EDIT

    Also, if logging out through the partner site, another method I have used in the past (which was with O2 and other such sites) they were given a 'callback' (REST API call in most cases) which they would also need to call when the user logs out of their site.

提交回复
热议问题