I have been building a skeleton application which handles user authentication, registering, requesting new passwords and so forth. I will post it when it's ready as I would like some feedback on how I've built it and whether I've gone about things in the right way.
Anyway, my question is regarding sessions. I have set the application up to store sessions in a MySQL database. I was wondering if it was possible to add extra columns for the session system to store data such as last login time, session start time and current session time?
You may check readSession() on how the data is read and used. Since you are adding extra columns to this session table, I assume you have your own code trying to read and analyze these extra data (e.g. showing how many people are online currently).
No, you should not try to extract information from the data column because that is in some serialized format.
You said you have extra columns. How do you plan to make use of them?
If you only need to access the current user’s last login time, session start time, etc., you don’t need to override CDbHttpSession at all. All you need are just to store those information as user session data and retrieve them like you usually do with session data.
Of course, sometimes the most obvious thing is the thing I miss. I am so used to do doing things in a procedural way as a pose to OO this is a little new to me. I have used OO for php for a while but not to this extent.
Basically I just wanted to link the current session to the user, and then I can do the bits I need to do, which now I can.