Magento – Add to cart in localhost doesn’t work in IE, Why

cartcheckoutmagento-1.7magento-enterpriseproduct

I have my development site in

http://localhost/mydevsite/

Everything is working fine, until I tested it in IE browser. When I click add to cart button (no changes made to this functionality), it gets redirected to cart page, but the cart is empty.

In other browsers, it is working fine. I use IE 10, also tested in IE9, IE8, IE7 (checked using the Browser Mode option). The problem prevails. I checked with both Magento CE and EE.

Is there a problem with IE settings, so that localhost websites doesn't hold cookies or something like that? Can anyone help me on this?

EDIT:
sorry I forgot to mention, I don't have permissions to edit hosts file, otherwise I could have created a virtual domain.
If other browsers can add products to cart, why not IE? I remember I have used loclhost in IE sometime back and it worked.

Best Answer

Don't use localhost as you host. For some reasons Magento needs a dot . in the host in order to be able to store cookies. Use 127.0.0.1 or add to hosts something like

magento.local    127.0.0.1

and use magento.local as your host.
You will need to change the base_url in core_config_data in order to make it work.
[EDIT]
This may offer a solution. It involves changing the way that the cookies are validated.