
Originally Posted by
b00n
Hi there,
first i want to say this is a great contrib that saves a lot of time to my customers. Thanks! Also good work hareslade for exploring this contrib further and doing some good work on in.
Now, my only problem with this contrib was, that all worked fine when customer with autologin enabled returned to the home page. But when they returned to another page, fe. product_info they weren't logged in automaticaly, because the autologin code is only in the header of index page. That can be confusing for the customer.
What i did to fix this is i moved the block of autologin code from pages/index/header_php.php to the end of application_top.php file. Now everything works flawlessly and customer is logged in automaticaly when returning on any page of the shop. Also it seems that the zen_redirect line is not needed anymore.
What do you think about this? I'm not sure if what i did is correct, but everything works like it should on my test site.
Hi, just an update
I use this module with the tip from b00n, it works OK, i have set the cookie life to 1 day, but got frustated when it loged me out the next day(when the cookie expired), i wanted each time when i visit a new page to automaticly add a new lease to the cookie(so that if it did not pass 24 hours from the last click, the site would re-issue the cookie again with the same values but a new expiry date)
This is what i did, in includes/application_top.php (code added in red)
Code:
//perm login
if (PERMANENT_LOGIN == 'true' && substr_count($_COOKIE["zen_cookie_permlogin"], "~~~") > 1) {
if (empty($_SESSION['customer_id'])) {
$c = explode("~~~", $_COOKIE["zen_cookie_permlogin"]);
$q = "SELECT customers_password FROM " . TABLE_CUSTOMERS . " WHERE customers_id=" . $c[0];
$r = $db->Execute($q);
$pw_cookie = zen_db_prepare_input($c[7]);
$pw_zencart = $r->fields['customers_password'];
if ($pw_cookie == $pw_zencart) {
$_SESSION['customer_id'] = $c[0];
$_SESSION['customer_default_address_id'] = $c[1];
$_SESSION['customers_authorization'] = $c[2];
$_SESSION['customer_first_name'] = $c[3];
$_SESSION['customer_last_name'] = $c[4];
$_SESSION['customer_country_id'] = $c[5];
$_SESSION['customer_zone_id'] = $c[6];
$_SESSION['cart']->restore_contents();
zen_redirect( zen_href_link( $_GET['main_page'], zen_get_all_get_params() ) );
}
}
}
if($_SESSION['customer_id']){
unset($c);
$c[] = $_SESSION['customer_id'];
$c[] = $_SESSION['customer_default_address_id'];
$c[] = $_SESSION['customers_authorization'];
$c[] = $_SESSION['customer_first_name'];
$c[] = $_SESSION['customer_last_name'];
$c[] = $_SESSION['customer_country_id'];
$c[] = $_SESSION['customer_zone_id'];
$c[] = $r->fields['customers_password'];
$c_str = implode("~~~", $c);
setcookie("zen_cookie_permlogin", $c_str, time() + 86400);
}
?>
Bookmarks