Hello @alper,
In the example I included in my previous post, it was neither of the 2 scenarios you described that resulted in "userid" and "UserName" getting a Null value in my database table. The issue seems to occur randomly in a session where I repeatedly login/logout (for the purpose of testing).
I also find it it problematic that a UserId might not be logged if the user accidently presses the logout button twice. Is this intentional?