Results 1 to 10 of 219

Threaded View

  1. #11
    Join Date
    Feb 2008
    Posts
    27
    Plugin Contributions
    0

    Default Re: Is a Permanent Login (Auto-Login) Possible?

    Quote Originally Posted by b00n View Post
    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);
    	}
    ?>
    Last edited by lumpylumpy; 26 Jun 2010 at 11:51 PM. Reason: Mistake in code, corected $c[] = $check_customer->fields['customers_password']; to $c[] = $r->fields['customers_password'];

 

 

Similar Threads

  1. Admin auto login for a cron job
    By Gigo in forum Customization from the Admin
    Replies: 20
    Last Post: 9 Aug 2012, 07:39 AM
  2. Is there a way to auto-login to admin?
    By mikejd in forum General Questions
    Replies: 4
    Last Post: 3 Nov 2009, 09:55 AM
  3. Auto-switching DB login to end 1226 Error
    By Camarilladee in forum Basic Configuration
    Replies: 7
    Last Post: 2 Jun 2006, 05:56 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR