Manually Logout from previous browser session if user login in any new browser in Cakephp 3

827 Views Asked by At

I am working on the Cakephp 3.

I need user only login once at time.

I am using Cakephp Auth component for the login into app. I worked with database session and cake session.

But when i am try to delete Session Manually from database or delete the session file form app/tmp/session, the session re-create again.

I don't want to disallow second login of user, but want to destroy previous session.

how can I achieve single session of user in Cakephp 3.

1

There are 1 best solutions below

3
On

You can store the current session id of the user in the users table:

  • Before login, check if the current session id is present in the users table for that user.

  • If the session id is present, destroy the old session by deleting it from the sessions table.

  • After login, store the generated session id.