When you open/launch minecraft, it connects to mojang's user login server. That server verifies your user/pass, and creates a session id based on your ip.
Then you attempt to connect to a server. That server checks with mojang to verify the ip connecting with the user is correct, and that the session id is correct. If so, you can login and play. If the session is incorrect (like you opened another client and logged in), it'll say "bad login".
However, we're all getting timeouts or 'took too long to respond' errors. This is because right now, the server side check servers at mojang are.... not working right. They are occasionally processing, but for the most part it's either too slow or just not working/responding at all.