Home » Magento7 July 2009

Magento Admin login problem

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:

Modify 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. These lines are present somewhere near line 80. You have to comment the comma (,) in line:

$this->getCookie()->getPath()//,

NOTE: Editing Core File is NOT a good practice. It is better to make a local copy of core file. Copy app/code/core/Mage/Core/Model/Session/Abstract/Varien.php to app/code/local/Mage/Core/Model/Session/Abstract/Varien.php and edit the local file.

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

Update (For Magento 1.4.*) and higher versions

In Magento 1.4 and higher versions, you have to comment code below which is present around line 80 to 100 in

app/code/core/Mage/Core/Model/Session/Abstract/Varien.php.

/*  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();
} */

NOTE: Editing Core File is NOT a good practice. It is better to make a local copy of core file. Copy app/code/core/Mage/Core/Model/Session/Abstract/Varien.php to app/code/local/Mage/Core/Model/Session/Abstract/Varien.php and edit the local file.

This might be a quick fix. However, it is better to find out the exact cause of your problem and then try fixing it. There can be different reasons behind this problem of admin login. Here is a proper answer to this issue: http://magento.stackexchange.com/a/26083/1883

Hope it helps.
Thanks.

From Mukesh Chapagain's Blog, post Magento Admin login problem

php magento mukesh chapagain

Get New Post by Email

Find me on

Facebook Twitter Google+ LinkedIn RSS Feed
  • Pingback: Magento Admin / Customer login problem | Repository

  • Manish Chauhan

     * I will want a way to flag an order as Sales Receipt or Invoice in Magento anyways so we can use that as a guide when we run a sync in T-Hub.Can this be made to show a color flag specific to Sales Receipt and a different color for Invoices in the Orders listing page in Magento?
        * Is there anything that can be shown visually to indicate in Magento that the order has already been synced to QB? Could this also be shown on the Magento Order listing page?

    can i get it in magento??

  • Numan_tahir1

    yaa nice work its working…. :)

  • http://twitter.com/aftabnaveed Aftab Naveed

    You Rock man!

  • Komal Web

    I have installed a copy magento in ubuntu which was working fine on windows.
    Not m facing a problem that which typing the admin url it is not displaying any login window. Frontend is working find. also I have checked rewrite module and curl. 
    Do you have any idea why the application is not working on ubuntu platform only for admin area.
    Also it is not displaying any error in log.

  • petrus

    cool

  • Jit

    Update (For Magento 1.5.*)
    // session cookie params
            $cookieParams = array(
                ‘lifetime’ => $cookie->getLifetime(),
                ‘path’     => $cookie->getPath()//,
                //’domain’   => $cookie->getConfigDomain(),
                //’secure’   => $cookie->isSecure(),
                //’httponly’ => $cookie->getHttponly()
            );

  • Hervé

    Also works with 1.6.
    Do not forget to comment line 104 :

    //call_user_func_array(‘session_set_cookie_params’, $cookieParams);

  • Nomonicker

    After searching the Web and trying various solutions this one finally worked!  Thanks for posting it!

  • Obreio

    thanks it works for me

  • Andy

    Editing the core file is not a good practice. Try duplicating the Varien.php with the folder structure in your local folder. This way it will not be affected when upgrading Magento versions.
    Cheers

  • Webdesigner9247

    you have saved my time thanks its working fine thanks

  • http://premiergoalandhighlight.blogspot.com/ wantknow

    Thank you, method 3 help me !!

  • Pingback: Magento site live vers site en local : le parcours du combattant « Creation de site Internet Inattendus (Les). 24H du Mans. Course. Agence de communication, evenementielle, hotesses, travaux, design, accueil, e commerce, impression, streetmarketing.

  • thankyou

    thanks it worked for me

  • mmbala

    Thanks Now I got my admin panel nice post

  • Ram

    Thanks Mukesh.

  • pivr

    bravo care

  • sopedro

    In my case the problema that the browser didn’t accept the magento cookies it’s all about clock settings. My pc was configured to update Windows time automatically. uncheck this option and put the right date and test again. Now the cookies are stored because de datetime it’s the same. Hope this helps…..

  • ds

    very thanks to you :)

  • Pingback: Magento安装完成后,后台不能登录 | Phnix

  • Glaux

    I use Magento 1.7 and after commenting out the comma I get the error: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ‘)’ in /home/mysite/public_html/app/code/local/Mage/Core/Model/Session/Abstract/Varien.php on line 89

  • Glaux

    Sorry my bad, didn’t realize you meant “from Magento 1.4 onwards” follow the updated instructions. Works now.

  • Sheyo

    it works fine. thanks

  • Jithin Lukose

    Thank you very much….

  • Lee

    Great Post. Led me in the right direction. I had to comment out lines 85 to 106 in Magento ver. 1.7.0.2 – I hope that does not mess anything up. Please comment if you think it will. Thanks in advance.

  • Pingback: Cannot login to Magento admin panel after installation | Dynamics AX

  • Kleeyo

    Ow thank you so much man.
    It was really a stupid thing, thanks to you it finally works on my localhost

  • niraj

    thanks for update, its solved my same issue

  • Nick Mc.

    Great article! One temp solution that helped me is by deleted only the local host site’s cookies and that helped too but is only temporary until it happens again. Your solution is more permanent but does change core code, even when overridden properly like you suggested.

  • http://dexteradams.me/ Dexter Adams

    Awesome! This worked for an install I was doing. Was racking my brain.

  • Mujahid

    Your the MAN, thanks dude … I started hating magento, I faced 5 problems installing it .. this problem was #5 i hope I don’t face #6

  • Navin Bista

    I know It works but do you think modifying the core magento file is a good option,should be other ways

  • alex

    Work like charm! Thanks dude! Btw I wonder why this Magento is hard even to install ?

  • Guest

    yeah it’s crazy. it doesn’t look very well made

  • jeryci

    great! in magenbto 1.9 this helped ;) lines are 91 to 93. thanks heaps!

  • slgarza

    Worked! thanks!

  • brainware

    Thanks, you safe my life today :)

  • http://michaelcalkins.com Michael Calkins

    It worked thanks!

    {{base_url}} is not recommended to use in a production environment to declare the Base Unsecure URL / Base Secure URL. It is highly recommended to change this value in your Magento configuration.

  • belansus

    Comment out ‘httponly’ => $cookie->getHttponly() on ~line 91 in Varien.php

    Clear cookies and cache, worked for me on Magento CE ver 1.9 – I don’t fully understand the importance of this, so please only use with caution.

    made accessible only through the HTTP protoc$cookie->getHttponly() – Makes cookie accessible only through the HTTP protocol

    made accessible only through the HTTP protoc

  • Kyuu

    Thanks… Worket Fine :) Magento 1.9.0.1