2016-11-21 04:47
浏览 61

在laravel 5.3中删除登录时的旧会话

How can I remove all expired user sessions from DB on login event ? I delete user session after log out. But sometimes a log out button not clicked and session expires and stay in DB.

I need delete all sessions from any machines for current user on user login event.

It possible or not in laravel 5.3?

图片转代码服务由CSDN问答提供 功能建议

如何在登录事件中从DB中删除所有过期的用户会话? 我在注销后删除了用户会话。 但有时候一个注销按钮没有被点击,会话就会过期并留在数据库中。

我需要在用户登录事件中从当前用户的任何机器上删除所有会话。 \ n

在laravel 5.3中是否可能?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doumi1944
    doumi1944 2016-11-21 05:00

    Yes. It is possible.

    1. Before User login, check for any existing sessions in database for same user. One architectural assumption here, all existing sessions should be expired and need to be deleted.
    2. If any exists, delete them.
    3. Make sure you create/insert entry for current login after you delete existing/expired sessions.

    For more information, you can check this question and relevant answers.

    点赞 评论