Man, I have no idea what's going on there. I suggest you follow the program flow for the login procedure, and put in die statements along the way to see how far it gets before it locks up.
die