Session help

I have a site that makes a log of certain things that happen.
If the user logs in it says user logged in at whatever time.
The problem is if two users are logged in a the same time then their activity is logged together and it gets mixed up
eg
UserA logged in at 12:15:33
UserB logged in at 12:18:45
UserA updated contentA at 12:16:00
UserA added a new item at 12:18:14
UserB updated contentB at 12:18.35
UserB logged out 12:20:03
UserA logged out 12:21.02

can i create a session to store the data together before it is output in the log file so they are grouped together
ie $_SESSION[‘user-log’] .= $variableMessage
to create a better log file like below

UserA logged in at 12:15:33
UserA updated contentA at 12:16:00
UserA added a new item at 12:18:14
UserA logged out 12:21.02

UserB logged in at 12:18:45
UserB updated contentB at 12:18.35
UserB logged out 12:20:03

Regards, Pierce

Could you please post the code that your using to generate the log text and save it to the log

I’m not quite sure how you would be able to do this unless you store the data in a db then run a job to sort the data during the export.