Building off of Phi's chat tutorial, you can make a login system for your chat too.
http://thenugget.tk/auth_tutorial.pdf