It's possible that sessions are not configured properly on your server. Please try calling the script http://yourserver/moodle/lib/session-test.php.
I also have the same problem
WHen I go to login page, it shows the message "Your session has timed out. Please login again." above the login box. WHen I try to login it brings me back to the home page but does not log me in.
I tried your suggestion and after calling the session-test.php it told me sessions are working correctly. But the problem persists. Any other suggestions?
Unity, please check the "stuck on the login screen" FAQ in MoodleDocs Installation FAQ for other possible causes.
I tried it myself but still not the solution. The suggestions in the MoodleDocs Installation FAQ also failed to solve my problem. Any other suggestions? Please help.