OSX Mountain Lion logs out after login
Solution 1:
Make sure you dont have Log-In options enabled. If they are, disable them. It sounds like you might be running a Log-In option.
Check out this link to learn more about Log-In options.
http://support.apple.com/kb/PH10650?viewlocale=en_US
EDIT: Since you don't have any log in options enabled, it sounds like it might just be a lag from the screen waking up.
Does this happen when you are attached to an external monitor as well? Or does it only occur when you open the lid?