I started to install a new version of Magento (1.4.0+) and I couldn’t log in to the backend (Admin page) of the website. After reading several threads and posts, I came to know the reason was because when installing on the localhost, I was trying to access it at the address http://localhost/magento, but because of some standard restrictions, browsers don’t save cookie for domains with no dot (.) in domain name (i.e., http://localhost is not a standard host name). Therefore the solution is to make the change of the address to something like: http://localhost.com/magento. It’s not that simple as it sounds, but it is also not that complicated either. I have done these steps and it works, so I guess so can you…

1.Change the Hostname to something like www.localhost.com

- Open the file "C:\Windows\System32\drivers\etc\hosts" with Notepad or any Text Editor

- Replace or Add “127.0.0.1 www.localhost.com“   (the existing one might be 127.0.0.1     localhost)

- Save the changes (Make sure it was saved, you need to have administrator right on the computer)

2. Reinstall Magento (if you haven’t installed, just install it)

- At the Option “Database Connection”, change the field host to www.localhost.com instead of localhost

- The rest of installation should be as normal

When you finished, you should be able to log in to the Admin page at the address http://www.localhost.com/{your-magento-folder}/admin or  http://www.localhost.com/{your-magento-folder}/index.php/admin