I have this login problem with my Ubuntu 12.10 installation, and the cure for it is listed here. It may work for other versions of Ubuntu, but there’s no guarantee.
Workaround for the Ubuntu 12.10 login problem
Sometimes Ubuntu 12.10 won’t let me login.
The graphical login screen appears as normal, but when I type my password and press Enter, the screen goes blank for a second, then goes straight back to the login screen again.
It’s almost as though my password is not being accepted, but I know it’s ok, as I can log into a console with it.
Here’s how to cure it:
Press Ctrl-Alt-F1 and do a console login using your normal username and password, then type:
sudo rm ~/.Xauthority
Enter your password, then press Ctrl-Alt-F7 to return to the graphical login screen.
You should now be able to log in.