Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6600857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:40:42+00:00 2026-05-25T18:40:42+00:00

I’ve extended the Mage_Adminhtml_CustomerController with a new action loginAction in order to be able

  • 0

I’ve extended the Mage_Adminhtml_CustomerController with a new action loginAction in order to be able to login as a customer from the admin interface.

I call the loginById on the customer/session, but the customer’s session isn’t modified after the redirect.

Can someone explain why? It should be a simple operation.

Here’s a gist containing the loginAction

I appreciate any help.

Thanks!


Update:

I created a github-repo containing all the code for the module: https://github.com/KATT/Magento-CustomerLogin.

Once this issue is solved, it might be useful for someone else as well.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:40:43+00:00Added an answer on May 25, 2026 at 6:40 pm

    Hi I created a way to login as a customer. With the following solution below you can get an action in the customer grid management view in backend for each customer:

    You have to create a controller for the frontend and do a class rewrite of an admin block, please adapt to your situation and don’t forget to create a xml file which activate your module at app/etc/modules/Yourmodule_Customer.xml
    Here is the config.xml of a module that you will have to create:

    <?xml version="1.0"?>
    <config>
    <modules>
        <Yourmodule_Customer>
            <version>0.1.0</version>
        </Yourmodule_Customer>
    </modules>
    <global>
        <blocks>
          <adminhtml>
            <rewrite>
              <customer_grid>Yourmodule_Customer_Block_Adminhtml_Overwrite_Grid</customer_grid>
             </rewrite>
           </adminhtml>
    </global>
    <frontend>
        <routers>
            <customer>
                <args>
                    <modules>
                        <customer before="Mage_Customer">Yourmodule_Customer_Overwrite</customer>
                    </modules>
                </args>
            </customer>
        </routers>
    </frontend>
    

    Then you have to create a block class in the folder Youmodule/Customer/Block/Adminhtml/Overwrite/Grid.php with the following content:
    Be aware that if you have Store Code in URL activated, you need here to provide a default store code.

    <?php
    class Yourmodule_Customer_Block_Adminhtml_Overwrite_Grid extends Mage_Adminhtml_Block_Customer_Grid
    {
        protected function _prepareColumns()
        {
            parent::_prepareColumns();
    
            $column = $this->getColumn('action');
            $actions = $column->getActions();
            $actions[] = array(
                'caption' => 'Log in',
                'popup' => true,
                'url' => array(
                    'base' => 'customer/support/autologin',
                    'params' => array('_store' => 'de', '_secure' => true)),
                    'field' => 'customerid'
            );
            $column->setActions( $actions );
    
            return $this;
        }
    }
    

    Then you have to create a new frontend controller, in this case, it’s restricted to authorized IP address defined in the backend configuration:

    <?php
    class Yourmodule_Customer_Overwrite_SupportController extends Mage_Core_Controller_Front_Action
    {
        public function preDispatch(){
    
            parent::preDispatch();
    
            if (!$this->getRequest()->isDispatched()) {
                return;
            }
    
            $action = $this->getRequest()->getActionName();
            $pattern = '/^(autologin)/i';
            if (!preg_match($pattern, $action) && Mage::helper('core')->isDevAllowed(Mage::app()->getStore()->getId())) {
                if (!$this->_getSession()->authenticate($this)) {
                    $this->setFlag('', 'no-dispatch', true);
                }
            } else {
                $this->_getSession()->setNoReferer(true);
            }
        }
    
        public function autologinAction(){
            $session = $this->_getSession();
    
            $id = (int) trim($this->getRequest()->getParam('customerid'));
            try{
                if($id){
                    $customer = Mage::getModel('customer/customer')->load($id);
                    $session->setCustomerAsLoggedIn($customer);
                    $message = $this->__('You are now logged in as %s', $customer->getName());
                    $session->addNotice($message);
                    Mage::log($message);
                }else{
                    throw new Exception ($this->__('Auto Loggin didn\'t worked. Some parameter are missing'));
                }
            }catch (Exception $e){
                $session->addError($e->getMessage());
            }
            $this->_redirect('customer/account');       
        }
    
        public function _getSession(){
            return Mage::getSingleton('customer/session');
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.