Re: Is a Permanent Login (Auto-Login) Possible?
v2.1.0 of "Remember Me" is now available for download: https://www.zen-cart.com/downloads.php?do=file&id=332
This release contains changes associated with these GitHub issues:
#20: Offer "Remember Me" on OPC's guest-to-account conversion.
#23: Redirect to home-page after customer's remembered.
#24: Correct PHP deprecations.
#25: Add $_SESSION['customer_email_address'] when a customer's remembered.
#26: Drop support for Zen Cart versions prior to 1.5.8 and PHP versions prior to 7.4.
#27: Don't remember admin 'Place Order' logins.
2 Attachment(s)
Re: Is a Permanent Login (Auto-Login) Possible?
The checkbox is not displayed (or not visible) with version 2.1.0 Remember Me, zen cart v1.5.8a, ZCA_bootstrap_template v3.7.5, and OPC v2.5.4 in every expected location. The Remember Me? label is displayed as expected. There are no error logs. I can not find any CSS that would hide the checkbox. An image from returning customer login is attached, as well as the page source html for the form (edited to remove domain and security token, and formatted (indented) for ease in understanding. Any suggestions would be appreciated.
Thank you!
Dave
Re: Is a Permanent Login (Auto-Login) Possible?
The html file in the previous post is not readable for some reason. The file is reproduced below:
Code:
<form name="loginForm" action="https://my_domain/index.php?main_page=login&action=process" method="post" id="loginForm">
<input type="hidden" name="securityToken" value="blah-blah">
<div class="opc-label">
<label for="login-email-address">Email Address:</label>
</div>
<input class="form-control" type="email" name="email_address" value="" size="18" id="login-email-address" autofocus placeholder="*" required>
<div class="opc-label">
<label for="login-password">Password:</label>
</div>
<input class="form-control" type="password" name="password" size="18" id="login-password" autocomplete="off" placeholder="*" required>
<br>
<input class="custom-control-input" type="checkbox" name="permLogin" value="1" checked="checked" id="permLogin">
<label class="checkboxLabel" for="permLogin" title="Tick this box to be automatically logged in on your next visit. Note: This will place create a cookie in your current browser that can only be read by this website.">Remember me?</label>
<div id="opc-pwf">
<a href="https://costore-158a.local/index.php?main_page=password_forgotten">Forgot your password?</a>
</div>
<div class="text-right">
<button type="submit" class="btn button_login">Sign In</button>
</div>
</form>
Dave
Re: Is a Permanent Login (Auto-Login) Possible?
Yep, checkbox type inputs require some special HTML; see this W3Schools link for additional information: https://www.w3schools.com/bootstrap4...rms_inputs.asp
Re: Is a Permanent Login (Auto-Login) Possible?
Quote:
Originally Posted by
lat9
Got it! I changed function create_checkbox starting on line 210 in class.remember_me_observer.php from:
PHP Code:
public function create_checkbox()
{
if (!$this->enabled) {
return '';
}
$return_value =
'<br>' .
zen_draw_checkbox_field ('permLogin', '1', $this->checkbox_default, 'id="permLogin"') .
'<label class="checkboxLabel" for="permLogin" title="' . TEXT_REMEMBER_ME_ALT . '">' . TEXT_REMEMBER_ME . '</label>';
return $return_value;
}
to:
PHP Code:
public function create_checkbox()
{
if (!$this->enabled) {
return '';
}
$return_value =
'<div class ="custom-control custom-checkbox pt-2 pb-2">' .
zen_draw_checkbox_field ('permLogin', '1', $this->checkbox_default, 'id="permLogin"') .
'<label class="custom-control-label" for="permLogin" title="' . TEXT_REMEMBER_ME_ALT . '">' . TEXT_REMEMBER_ME . '</label>' .
'</div>';
return $return_value;
}
The pt-2 and pb-2 are for spacing.
Dave
Re: Is a Permanent Login (Auto-Login) Possible?
Quote:
Originally Posted by
Dave224
Got it! I changed function create_checkbox starting on line 210 in class.remember_me_observer.php from:
PHP Code:
public function create_checkbox()
{
if (!$this->enabled) {
return '';
}
$return_value =
'<br>' .
zen_draw_checkbox_field ('permLogin', '1', $this->checkbox_default, 'id="permLogin"') .
'<label class="checkboxLabel" for="permLogin" title="' . TEXT_REMEMBER_ME_ALT . '">' . TEXT_REMEMBER_ME . '</label>';
return $return_value;
}
to:
PHP Code:
public function create_checkbox()
{
if (!$this->enabled) {
return '';
}
$return_value =
'<div class ="custom-control custom-checkbox pt-2 pb-2">' .
zen_draw_checkbox_field ('permLogin', '1', $this->checkbox_default, 'id="permLogin"') .
'<label class="custom-control-label" for="permLogin" title="' . TEXT_REMEMBER_ME_ALT . '">' . TEXT_REMEMBER_ME . '</label>' .
'</div>';
return $return_value;
}
The pt-2 and pb-2 are for spacing.
Dave
Sweet! I'll steal that for the next release, using the current return-value unless a bootstrap template is active in which case I'll use yours.
Thanks for the update.
Re: Is a Permanent Login (Auto-Login) Possible?
I'm having trouble with Remember Me restoring products in the cart when the customer comes back to the site. I'm not sure what the customer should see. For example, a customer enters their email address, password and clicks Remember Me to log in. Then a product gets added to the cart. For whatever reason, the site is left (without logging out). After the session has expired, the customer comes back to the site. The home page is displayed and the customer is logged in. I would expect the shopping cart link to be displayed in the header, and on clicking it, the product previously left in the cart would appear. But there is no way to get to the shopping cart page except by adding another product. But when doing so, only the just added product is present.
After leaving the site again, I checked the customer's basket in the database, and both products are present. The cookie expiration time is set for 400 days.
What am I missing or forgetting?
Thank you.
Dave
zc 1.5.8a, latest versions of Remember Me, Bootstrap template, and OPC.
Re: Is a Permanent Login (Auto-Login) Possible?
In trying to debug restoration of cart contents, I set PERMANENT_LOGIN_DEBUG to true in class.remember_me_observer.php and added a trigger_error statement to log $this->customer_remembered in function __construct() after $this->customer_remembered is initialized to false. I also added trigger_error statements to log the same variable in function checkRememberCustomer just after $this->customer_remembered is set to true, and also at the start of function restoreRememberedCart() before any tests. I suspected a potential timing issue.
The remember me debug log showed that cartIdSet was true in the cookie when returning to the site with a product placed in the cart previously before leaving the site. It was recorded first. Next, an error log showed that $this->customer_remembered was false in function __construct(), and true in function checkRememberCustomer. Finally, a third error log was recorded about 0.3 seconds later showing that $this->customer_remembered was set back to false in function __construct(), and false in function restoreRememberedCart.
So although the processing in function checkRememberCustomer correctly set $this->customer_remembered to true, subsequent processing reinitialized it to false, preventing function restoreRememberCart from restoring the cart.
I hope this helps figuring out what needs to be fixed.
Dave
Re: Is a Permanent Login (Auto-Login) Possible?
v2.1.1 of "Remember Me" is now available for download: https://www.zen-cart.com/downloads.php?do=file&id=332
This release contains changes associated with these GitHub issues:
#31: Use now-current PHP hash instead of md5 for various string hashes.
#28: Remember me? checkbox not visible when using Bootstrap template.
#32: A remembered customer's cart isn't also remembered.
#33: Correct interoperation with square_webPay (and other) payment modules when a customer is 'remembered'.
#34: Use zc158+ language-file array-format.