I am not sure correctly
Using session id depend more the way you work. The point of it i cant tell you exactly.
but there is a way to get the session id
session_id() will give you the id of the user session.
you could create a table that looking like this
--------------------------------------------------
id | master_id | sessionid | login(date)|logout(date)|
--------------------------------------------------
afeter when you start the session juste add this isert
insert into session values('','','the_master_id', 'session_id(),'now()','')
a the log out do the same but add the where in you msql querry make sure you use the session_id to call the right line cuze some one could comme more thant once so the master id is not the right thing to reffer you could also look for the the table id
i hope is what you want