Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 3 of 3
Remember me box on login page
 
vivek291186
Jr. Member
 
Avatar
Total Posts:  8
Joined:  2010-01-26
Delhi
 

Step for Remember me functionality in login.phtml
Step 1:
For version magento-1.3.2.4: Please find the following path
http:\\yourdomain\app\code\core\Mage\Customer\controllers \AccountController.php
For version magento-1.4.1.0: Please find the following path
yourdomain\app\code\core\Mage\Customer\controllers\AccountController.php

Find following function:

public function loginPostAction()

Replace with:
public function loginPostAction()
{
if ($this->_getSession()->isLoggedIn()) {
$this->_redirect(’*/*/’);
return;
}
$session = $this->_getSession();

if ($this->getRequest()->isPost()) {
$login = $this->getRequest()->getPost(’login’);
if (!empty($login[’username’]) && !empty($login[’password’])) {
try {
$_SESSION[’user_name’] = $login[’username’];
$_SESSION[’user_password’] = $login[’password’];
$session->login($login[’username’], $login[’password’]);
if ($session->getCustomer()->getIsJustConfirmed()) {
$this->_welcomeCustomer($session->getCustomer(), true);
}
}
catch (Exception $e) {
switch ($e->getCode()) {
case Mage_Customer_Model_Customer::EXCEPTION_EMAIL_NOT_CONFIRMED:
$message = Mage::helper(’customer’)->__(’This account is not confirmed. <a href="%s">Click here</a> to resend confirmation email.’,
Mage::helper(’customer’)->getEmailConfirmationUrl($login[’username’])
);
break;
case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD:
$message = $e->getMessage();
break;
default:
$message = $e->getMessage();
}
$session->addError($message);
$session->setUsername($login[’username’]);
}
} else {
$session->addError($this->__(’Login and password are required’));
}
}

$this->_loginPostRedirect();
}

Find following function:
protected function _loginPostRedirect()
Replace With following function:
protected function _loginPostRedirect()
{
$session = $this->_getSession();

if (!$session->getBeforeAuthUrl() || $session->getBeforeAuthUrl() == Mage::getBaseUrl() ) {

// Set default URL to redirect customer to
$session->setBeforeAuthUrl(Mage::helper(’customer’)->getAccountUrl());

// Redirect customer to the last page visited after logging in
if ($session->isLoggedIn())
{
if (!Mage::getStoreConfigFlag(’customer/startup/redirect_dashboard’)) {
if ($referer = $this->getRequest()->getParam(Mage_Customer_Helper_Data::REFERER_QUERY_PARAM_NAME)) {
$referer = Mage::helper(’core’)->urlDecode($referer);
if ($this->_isUrlInternal($referer)) {
$session->setBeforeAuthUrl($referer);
}
}
}
} else {
$session->setBeforeAuthUrl(Mage::helper(’customer’)->getLoginUrl());
}
}
//$customer12 = Mage::getModel(’core/cookie’);
//echo $lifetime = Mage::getStoreConfig(self::XML_PATH_COOKIE_LIFETIME_LONG, $customer12->getStore());

if(isset($_REQUEST[’rememberme’]) && $_REQUEST[’rememberme’] == ‘remember’)
{
$user_name = $_SESSION[’user_name’];
$pass_user_name = $_SESSION[’user_password’];
$cooki = Mage::getModel(’core/cookie’);
$cooki->set(’user_name’,$user_name);
$cooki->set(’pass_user_name’,$pass_user_name);
}
$this->_redirectUrl($session->getBeforeAuthUrl(true));
}

Step 2:
Find following file
http:\\yourdomain\magento\app\design\frontend\default\default\template\customer\form\login.phtml
Add following code top of login.phtml
<?php
$cooki = Mage::getModel('core/cookie');
$cookie_user_name = $cooki->get('user_name');
$cookie_user_password = $cooki->get('pass_user_name');
?>

Find following code in login.phtml
<input name="login[username]" value="<?php echo $this->htmlEscape($this->getUsername()) ?>” title="<?php echo $this->__('Email Address') ?>” id="email" type="text" class="input-text required-entry” style="width:250px;" />
Replace with following code:
<input name="login[username]" value="<?php if($cookie_user_name != ''){ echo $cookie_user_name;}else{ echo $this->htmlEscape($this->getUsername()); } ?>” title="<?php echo $this->__('Email Address') ?>” id="email" type="text" class="input-text required-entry” style="width:250px;" />
Find following code in login.phtml
<input name="login[password]" type="password" class="input-text required-entry validate-password” id="pass" style="width:250px;" />

Replace with following code:
<input name="login[password]" type="password" class="input-text required-entry validate-password” id="pass" style="width:250px;" value="<?php if($cookie_user_password != ''){ echo $cookie_user_password;}?>” />

Find the line as follws:
<p class="required"><?php echo $this->__('* Required Fields') ?></p>
Add the following line after
<div> <input type="checkbox" name="rememberme" value="remember" /> Remember me. </div>

 
Magento Community Magento Community
Magento Community
Magento Community
 
Boatmagic
Sr. Member
 
Avatar
Total Posts:  91
Joined:  2010-08-14
 

Thanks for this code everyone.

The only thing I don’t like about it is that it automatically fills in the password with a bunch of *********** until you put your login name in then it fills in your stored password.

I’m not complaining cos I sure couldn’t have figured out this..lol

 
Magento Community Magento Community
Magento Community
Magento Community
 
clockworkgeek
Sr. Member
 
Avatar
Total Posts:  79
Joined:  2009-07-31
 

I’ve just found and read this thread and so far have seen two approaches.

The first is the one overrides “getLifetime” to look for the checkbox. But the checkbox is only on the login page, on all pages after that the lifetime goes back to normal, which doesn’t help.

The other is a rather foolish way which has the following line,

$cooki->set(’pass_user_name’,$pass_user_name);
This is transmitting the user’s password in plain text and storing it in an unprotected cookie. I do not recommend this at all.

I can use neither so I have created this extension instead. http://www.magentocommerce.com/extension/5039/clockworkgeek_rememberme

 
Magento Community Magento Community
Magento Community
Magento Community
 
Lotar
Jr. Member
 
Total Posts:  1
Joined:  2010-06-30
 

Here you go: http://inchoo.net/ecommerce/magento/remember-me-checkbox-module-in-magento/

Cheers!

 
Magento Community Magento Community
Magento Community
Magento Community
 
govind123
Jr. Member
 
Total Posts:  21
Joined:  2009-06-14
 

Hi,

I have tried “Inchoo” Remember me but its not working in my application version 1.4.2.0. Just extracted the dowloaded zip into app folder.

I have added the checkbox field in my custom theme login.phtml. No other changes I made.

If I run the application it won’t work. I didn’t get any error message. After analysis I found that the “llocal\Inchoo\Remember\controllers\Frontend\Customer\AccountController.php” file not executed.

Where I made wrong. Please help me on this.

Thanks in Advance!

 
Magento Community Magento Community
Magento Community
Magento Community
 
vitotafuni
Jr. Member
 
Avatar
Total Posts:  11
Joined:  2011-12-12
 

Our extension work on every browser and don’t overwrite any mangeto core classes.
http://www.magentocommerce.com/magento-connect/catalog/product/view/id/13418/

 
Magento Community Magento Community
Magento Community
Magento Community
 
g0rdian
Member
 
Total Posts:  65
Joined:  2011-12-04
 

I was poking around on an Enterprise build that needs this functionality and I saw artifacts of it within the native Magento code. Turns out it’s already built-in on EE 1.12 and CE 1.7. The quickest way to enable it is System->Configuration->Customers->Persistent Shopping Cart->General Options->Enable Persistence. Once you change the select box to “Yes” you will see a great list of options to enable Magento’s native “Remember Me” functionality along with some other goodies.

 
Magento Community Magento Community
Magento Community
Magento Community
 
teetuan
Jr. Member
 
Total Posts:  1
Joined:  2013-04-16
 

Hi Lotar,

I viewed you module “remember me” but I wonder the result of this module. Normally, magento will save user in cookie when they logined. When I do research in your code, I’ve seen that you create new cookie to store user info. What is the effect, if I login and do not tick remember. Magento system till keep user status when they close browser.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 3 of 3