To do this, modify the /core.php configuration to use database-driven sessions.
Configure::write('Session.save', 'database');
After that, also uncomment the following line:
//Configure::write('Session.database', 'default');
Using the default database configuration is what you want in most cases.
Then prepare your database for hosting sessions using the Cake console:
cake schema create Sessions
Finally, in your login action, check if a session already exists for the user who has just logged in and is invalid / removes his old session from the session table.
I have not used this method before, but I assume that the user ID / username is stored in the data field of the session table (it probably contains a serialized array or something like that).
source share