CakePHP 2.0 – Storing Sessions in the database and retrieving online users

Notice

An updated version of this article is available here: CakePHP 2.8.x: Storing Sessions in the Database Revisited

Preface

Because I want to make this example as easy to understand for everyone, I will write it in English. I’m not a native speaker / writer so there might be some grammar errors for which I apologize in advance.

Preamble

What I will be covering today is how to configure your CakePHP 2.0 system to use your database to store user sessions, if you have one obviously. This could be useful to manage multiple sessions from different devices / ip addresses and to make sure no one else is signed in when you sign in somewhere else. Those parts I won’t be covering today, because that wouldn’t make this a small-tutorial =]. What I will be covering is something I find to be extremely handy in some situations, and that’s a method that shows you who’s online by checking recent session data.

Lees verder CakePHP 2.0 – Storing Sessions in the database and retrieving online users