Local Magento with MAMP – Unable to login to admin

I’ve probably already blogged about this but I’m sticking it on the new site so I don’t forget where I put it…

There’s a little bug with MAMP and Magento – this bug occurs when you try to login to the admin area.

When using MAMP we normally browse our local website by using http://localhost:8888. Unfortunately Magento does not allow itself to set cookies for this type of domain name. It will simply access your login credentials and then kick you back to the admin login screen.

To fix this locally, you can either change your URL so that you are using instead of localhost:8888 or alternatively you can edit the following core file (just make sure when you go live you undo this change).

In app>code>core>Mage>Core>Model>Session>Abstract>Varien.php find the following code and comment out the line as shown:

        // session cookie params
        $cookieParams = array(
            'lifetime' => $cookie->getLifetime(),
            'path'     => $cookie->getPath(),
            'domain'   => $cookie->getConfigDomain(),
            'secure'   => $cookie->isSecure(),
            //'httponly' => $cookie->getHttponly()

That should do the trick!

  • daniel_c_long

    Excellent little trick Rob, which I still use to this day! One other line of code which I’ve found needed to be commented out is around line 100 and looks like this:

    call_user_func_array(‘session_set_cookie_params’, $cookieParams);

    Although this is the only time I’ve ever had to comment this line!