Login doesn't work or must be done twice
There are at least two possible reasons why you can experience a symptom of "Visit the site, login, and while the username and password are correct the user does not appear to be logged in."
Cookies
Make sure cookies are enabled in your browser.
Cache Problems
It seems that sometimes the cache doesn't get updated when logging into a site so even after logging in the user is still shown the cached version of the site: not logged in. The source of this problem (browser, webserver, Drupal settings) is not completely understood.
One solution seems to be to disable the Drupal cache of the site, though that has the undesired side effect of increasing the load on your site.
Another workaround is for the users to hit the browser refersh button which seems to work fairly well, but has the drawback of not being easily discoverable and is a hassle for every user of the site. On a site where only one or two users login, this is not a problem. On a community site it is a bigger problem.
For the next version of Drupal - the problem is fixed as a result of this issue.
Logging in at www on a site with no www in the baseurl
This problem is more easily understood and fixed. If a site is set with http://example.com as the base URL and the user types www.example.com into his URL then he will still be presented the main page. When the user uses the login block to login then Drupal will send them a cookie with www.example.com as the domain and will forward the user to http://example.com where the cookie will not be valid and the user will not be logged in. One solution to this problem is to configure your server so that the URL and the Drupal settings match perfectly. If you are using apache and .htaccess is enabled you can achieve this with an .htaccess rewrite directive inside of the "Various rewrite rules" section:
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]While the example has always been to remove the www, the problem and this solution can be reversed for adding www.
This second issue has been fixed for the "next" version of Drupal in this issue

The code provided above
The code provided above didn't work for me (4.7.4).
But after browsing around, I found this other one, which DID work (don't ask me why!):
RewriteCond %{HTTP_HOST} ^www.example.comRewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
Please notice that this change won't prevent your site from being accessed by one version of URL (with or without www.), as someone may think (like me, when first read this page). It will only force the url to be rewritten to the format you choose, if an user types the other one.
And here's one to flip it the other way
#Add the leading 'www' to all URLsRewriteCond %{HTTP_HOST} ^example\.org$ [NC]
RewriteRule ^(.*)$ http://www.example.org/$1 [L,R=301]
This one's nice. While the others I've found deliver you to the front page (ie, they redirect from http://example.org/whatever to http://www.example.org, which is kinda frustrating), this one takes you to the page you were looking for in the first place (ie, from http://example.org/whatever to http://www.example.org/whatever).
Thank you very much for that
Thank you very much for that .htaccess fix. It removed a lot of users' frustrations with our site.