Home » Magento

Magento Admin login problem

7 July 2009 2,021 views 11 Comments

Problem:

I had a new installation of magento. But I was unable to login as an administrator. I went to the admin login page, entered correct username and password but was redirected to the same login page. I could not enter the dashboard page. Error message is displayed when I enter wrong username or password. But nothing is displayed and I am redirected to the same login page when I insert correct username and password.

Solution:

I googled and found these solutions:-

1) Use 127.0.0.1 instead of localhost in your url, i.e. using http://127.0.0.1/magento/index.php/admin instead of
http://localhost/magento/index.php/admin . But this didn’t solve my problem.

2) Since I am using Windows XP, I was suggested to open “host” file from
C:\WINDOWS\system32\drivers\etc and have 127.0.0.1 point to something like magento.localhost or even 127.0.0.1 point to http://www.localhost.com . But this also didn’t work either.

3) This solution finally helped me out of this problem. The solution was to modify the core Magento code. Open app/code/core/Mage/Core/Model/Session/Abstract/Varien.php. Comment out the lines 80 to 83. The line number may vary according to the Magento version. But these lines are present somewhere near line 80. You have to comment the comma (,) in line: $this->getCookie()->getPath()//,

// set session cookie params
session_set_cookie_params(
$this->getCookie()->getLifetime(),
$this->getCookie()->getPath()//,
//$this->getCookie()->getDomain(),
//$this->getCookie()->isSecure(),
//$this->getCookie()->getHttponly()
);

Well, I am out of this problem. Hope, this solution you also help you.

Update (For Magento 1.4.*)

In Magento 1.4, you have to comment code from line 86 to 98 in app/code/core/Mage/Core/Model/Session/Abstract/Varien.php. Like this:-

/*  if (!$cookieParams['httponly']) {
	unset($cookieParams['httponly']);
	if (!$cookieParams['secure']) {
		unset($cookieParams['secure']);
		if (!$cookieParams['domain']) {
			unset($cookieParams['domain']);
		}
	}
} 

if (isset($cookieParams['domain'])) {
	$cookieParams['domain'] = $cookie->getDomain();
} */

Popularity: 100%

Related posts:

  1. Magento: Set Unset Session
  2. Configuration error on new Magento installation
  3. Magento: Access denied in admin of custom module
  4. Magento: Create, read, delete cookie
  5. Session Handling in PHP
Share/Bookmark
1 Star2 Stars3 Stars4 Stars5 Stars (7 votes, average: 5.00 out of 5)
Loading ... Loading ...

11 Comments »

  • Sanat Hegde said:

    It works!

    But will it affect automatically updating magento in the future?

  • Mukesh said:

    This might affect upgrading magento in future. Alternatively, at the time of installation, you can use ‘127.0.0.1′ instead of ‘localhost’.

    If you have already installed magento, then you have to change some values in database.

    Open core_config_data table of your magento database.

    Edit the value with the path ‘web/unsecure/base_url’. Keep 127.0.0.1 instead of localhost.

    Now, browse http://127.0.0.1/your_installation_folder

    Thanks,

  • Rakesh said:

    i am developing a b2b website in magento, but at first i want to make the login/registration page as the home page, how can i do this?

  • Admin GammaLogics said:

    Thanks it really worked man ,

  • Ivan said:

    Great!, it works. Thanks!

  • chandra said:

    thaks, great job

  • trevor said:

    Didnt work for me. Now I get an error, I dont even get to the login page.

    There has been an error processing your requestException printing is disabled by default for security reasons.

    Error log record number: 882398834

    I guess I am the only one!!, googled everywhere and no one else is having this problem.

    Any ideas?

  • Mukesh said:

    @trevor: Please recheck if you have commented the lines properly. There are 3 lines to be commented and a COMMA in the line above those 3 lines ($this->getCookie()->getPath()//,)

  • mukul said:

    i have commented these line but then an another error occurs
    There has been an error processing your request
    Exception printing is disabled by default for security reasons.

    Error log record number: 939170623

  • mukul said:

    in my file code is
    $cookieParams = array(
    ‘lifetime’ => $cookie->getLifetime(),
    ‘path’ => $cookie->getPath(),
    ‘domain’ => $cookie->getConfigDomain(),
    ’secure’ => $cookie->isSecure(),
    ‘httponly’ => $cookie->getHttponly()

  • Mukesh said:

    Hi Mukul,

    It seems that you are using Magento 1.4. There is some change in Varien.php code in Magento 1.4.

    In Magento 1.4, you have to comment code from line 86 to 98. Like this:-


    /* if (!$cookieParams['httponly']) {
    unset($cookieParams['httponly']);
    if (!$cookieParams['secure']) {
    unset($cookieParams['secure']);
    if (!$cookieParams['domain']) {
    unset($cookieParams['domain']);
    }
    }
    }

    if (isset($cookieParams['domain'])) {
    $cookieParams['domain'] = $cookie->getDomain();
    } */

    Hope this helps.

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.