hey,
how could it be possible to let users "stay logged in on this computer" (auto / permanent login)?
thx
Printable View
hey,
how could it be possible to let users "stay logged in on this computer" (auto / permanent login)?
thx
Sure, you just need to set a cookie, and configure the Zen Cart login to look for it.
http://us2.php.net/manual/en/features.cookies.php
Then take a look at...
- [STORE_ROOT]/includes/modules/pages/login/header.php
- [STORE_ROOT]/includes/modules/create_account.php
okay, that works really nice.
but since it's so easy to modify cookies, how to make it safe?
store the password as md5-string in the cookie?
The cookie should definitely have the PW encoded.
sorry, but WHY wouldn't you take md5-encryption for the customers password?
zen_validate_password doesn't help any, because that function deals with the unencrypted password as value.
in the cookie i have an md5... and the function zen_encrypt_password always produces a different string...
how would you suggest to compare the md5-pw to the one in the db?
sorry, my mistake.
of course i can store the password from the db in the cookie and have not to deal with this extendet encryption method :P
Is this explained (i.e. a step-by-step how-to with code examples) anywhere for people like me - non-programmers but willing to have ago?
I'll rephrase that - does anyone have a step-by-step guide as how to incorporate this in ZC? Or better still, a contribution? :wink2:
okay, i'll write a brief explanation of that.
but tomorrow... :P
hi.___
- first of all, add a checkbox to your login-form called something like "permLogin".
_- edit the file "/includes/modules/pages/login/header_php.php"
if the login is ok, zencart will proceed to the beyond line 57 and does all the stuff around line 70. just after this we hook in. put that code there:
_
if (!empty($_REQUEST["permLogin"])) {
___ 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[] = $check_customer->fields['customers_password'];
___ $c_str = implode("~~~", $c);
___ setcookie("zencart_cookie_permlogin", $c_str, time()+36000000);
}
___
this will store all the relevant information in the cookie.
___- edit the file "/includes/modules/pages/index/header_php.php"
if you start your zencart, this page will be loaded. here we check if the login is set and if, then we login automatically.
at the very top of that file, just after "$zco_notifier..." add this code:
___
if (substr_count($_COOKIE["zencart_cookie_permlogin"], "~~~") > 1) {
___ if (empty($_SESSION['customer_id'])) {
______ $c = explode("~~~", $_COOKIE["zencart_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();
______ }
___ }
}
___
Thats pretty much it
:smile:
Thankyou - much appreciated.
Ok, I have done a few searches, but I couldn't find anything definitive.
Quote:
add a checkbox to your login-form called something like "permLogin".
How would I go about adding a checkbox. From your instructions I can definately do the rest, but the checkbox stumps me.
Oh and thank you very much for the instructions, I love that my customers can be logged in all of the time.
Pat
hey, no problem!
it's a template file you should first copy into your own template-directory.
- copy the file "includes/templates/template_default/templates/tpl_login_default.php" to "your_template_dir/templates/tpl_login_default.php"
_- in this file the login box is around line 50. just there add the checkbox with a code like that:
"<input id="permLogin" name="permLogin" type="checkbox" checked> stay logged in"
Good stuff, crazy_chris. :thumbsup:
Hi crazy_chris, I just wanted to stop by and thank you for this.
I haven't got it working yet, (I got the tick box and the cookie imbeds it'self, but it does not log me back in again) but I will play around with it and I am sure I will be able to figure it out. It is likely I just put the code in the wrong spot, so I will look at the logic of the statements.
Again, thanks
Pat
Hmm - I get this errorAnd the code I have copied and pasted from above and placed exactly where recommended in includes/modules/pages/login/header_php.php isCode:1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
in:
[SELECT customers_password FROM zen_customers WHERE customers_id=]
I'm no expert, but there doesn't seem to be anything wrong with that. And I've checked in the db that the required data is present. :unsure:Code:if (substr_count($_COOKIE["zencart_cookie_permlogin"], "~~~") > 1) {
if (empty($_SESSION['customer_id'])) {
$c = explode("~~~", $_COOKIE["zencart_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();
}
}
}
hey, is this a joke... because you just put the lines in the wrong file!! :blush:
the code you just posted (for automatically logging in) is meant to be put in "/includes/modules/pages/index/header_php.php"
the file "includes/modules/pages/login/header_php.php" (where you put the mentioned code) is for the original login-process where you set the cookie for the permanent login.
:P if you experience any troubles, post again!
Damn - my human side is showing again! :D
But actually, not as bas as it seemed...I HAD put it in the right place - I had just pasted the wrong filename in that previous post.
hehe, alright then :P
well, it seems, it doesn't find the customer_id in the cookie.
could you please add this code before the "$c = explode(....)":
"echo $_COOKIE["zencart_cookie_permlogin"];"
and post the output here?
Will do . but while I'm doing that, could you be a bit more specific aboutShould it be at about line 72 after $check_country or about line 80 after the $_SESSION lines?Quote:
does all the stuff around line 70. just after this we hook in. put that code there
This one is in login/header_php.php
no, 72 is too early, better go around 90 after the "$_SESSION['..." part.
the best place is just after $_SESSION['cart']->restore_contents(); which is line 91 here.
this is very important and might likely be the reason for your problem :P
OK, that's all working now, and thanks very much for your help.
Now please don't take this the wrong way because you've done excellent work here and I really appreciate your assistance, but remember that what seems obvious to you when you're talking about code is not necessarily obvious to non-coders. If you could be as specific as possible (eg. "line 123 on an original copy of filename blah blah" or, as you just did "just after $_SESSION['cart']->restore_contents();") that makes life sooo much easier for old duffers like me! :laugh:
Now I intend to package this up in the proper ZC module release package format if that's OK by you, and upload it to the downloads section. You will of course be credited for the code.
hey,
fine that it's working!
thanks for the feedback - i see what you mean and totally agree. i'll try to be more specific in the future :)
if you want to realease it as module, go ahead. good idea, because zc is just lacking of that permanent login. for the credit please include "chris at linuxuser.at"
best greetings from austria,
chris
The checkbox needs to be added twice to account for the Split login option, so in includes/templates/YOUR_TEMPLATE/templates/tpl_login_default.php
At about line 52, afterinsertCode:<label class="inputLabel" for="login-password"><?php echo ENTRY_PASSWORD; ?></label>
<?php echo zen_draw_password_field('password', '', 'size="18" id="login-password"'); ?>
<br class="clearBoth" />
and at about line 85 (having done the above), just afterCode:<!--BOF Remember Me-->
<label class="checkboxLabel" for="login-remember"><?php echo TEXT_REMEMBER_ME;?></label>
<?php echo zen_draw_checkbox_field('permLogin', '1', false, 'id="permLogin"');?>
<br class="clearBoth" />
<!--EOF Remember Me-->
insertCode:<label class="inputLabel" for="login-password"><?php echo ENTRY_PASSWORD; ?></label>
<?php echo zen_draw_password_field('password', '', zen_set_field_length(TABLE_CUSTOMERS, 'customers_password') . ' id="login-password"'); ?>
<br class="clearBoth" />
Code:<!--BOF Remember Me-->
<label class="checkboxLabel" for="login-remember"><?php echo TEXT_REMEMBER_ME;?></label>
<?php echo zen_draw_checkbox_field('permLogin', '1', false, 'id="permLogin"');?>
<br class="clearBoth" />
<!--EOF Remember Me-->
The problem with this as presented above is that the customer remains permanently logged in - which could irritate them. With the help of Kuroi who has added to crazy_chris's code, we are now able to offer an enhanced version which allows the store owner to set whether Automatic Login is on/off via admin AND if it is on, the customer can select log off if s/he wishes.
The customer can choose the auto login option either at account creation or at any time they log in.
Thanks to both crazy_chris and kuroi, this has now been submitted as a contribution to the downloads section in "Other Modules" - in the meantime, you can get it here...
Nice one :thumbsup:
Downloaded and added to my infinite todo list :smartass:
Edit: hey the download isn't counted..
this looks good...
well done ryk!
:bigups:
The credit goes to you and kuroi - all I did was package your work to make it easier for other folks like me.
I'd venture to suggest that, with the addition of the admin switchery by kuroi, that this could now be something that may find it's way into the core of ZC.
Ok, I have tried this a couple of times now and I wonder if I could get some help.
I fooled around with the first go around, and I could not get my computer to stay logged in, and I tried it at two different locations.
I then went and downloaded the final version from the contributions. This did not work either. Here is what is happening.
Under the "Create a Customer Profile" I get "TEXT_REMEMBER_ME" next to the tick box at the end of the new customer information. The other logon (login) area has the correct text.
I log in on either side, with a new sign up and a new login and it logs me in fine, but when I leave and come back, I am logged out again.
I have checked and updated the admin to turn on the automatic login in the "Customer Details" area, which was already reading true.
I submitted my sql database changes, so hopefully that is fine as well.
I get the cookie "zencart_cookie_permlogin"
Does anyone have any ideas what may be happening?
Thanks Pat
Quote:
copy create_account.php
from:
includes\languages\english\
to:
includes\languages\english\your template
add:
define('TEXT_REMEMBER_ME', 'the text you want to add');
Thanks for that ryhn, that did get the text fixed, but it did not fix the actual problem getting logged in permanently.
I think I have spent way too much time on this (hours) going over each line of code, I even tried the other headers that were included in the down load, but I have to give up.
Bottom line, this package/module does not work. I have downloaded from the link on this thread and from the package on the downloads section and after it is all said and done, I do not stay logged on.
I get the cookie but when I return I am not logged in. I have tried it from two different computers/ operating systems and still no go.
Back to pumping in my products,
Pat
Please be accurate - this does not work for you. I have it working perfectly for a client at www.fastlec.co.uk - or to be accurate myself, I stay logged in and there's been no complaints from his customers that I'm aware of.
I understand what you are saying and I don't doubt that you have the permlogon working. I would speculate though that you did not get it working from the posted mod.
If I am wrong I apologize.
Seriously though, I have installed quite a few mods and I have every one working. I don't know php, but I do understand the file structure and the basics of how it all works. I can get almost anything working, but for the life of me I can not get this mod to keep me logged in.
I would be interested to hear that someone else has got this mod working from the mod package or the download on this link.
Thanks Pat
I was the one who packaged this up following the coding work of crazy_chris and kuroi, and the packaging was done after ensuring it worked.
The mod has been downloaded 211 times - apart from yourself, no-one else has posted to say they've had problems. Now I'm not saying that means that nobody HAS had trouble, but with no other issues reported, it does look as if there is something unique to yourself.
Don't forget, people rarely post to say something IS working - which means that the successful ones may not see your request as they won't be subscribed to this thread.
All I can suggest is that you re-download and re-install, just in case something got corrupted.
Thanks Ryk for keeping an eye on this thread.
I have downloaded each of the packages (from this thread and the main download area) twice each and tried installing it four different times from two different pysical pc locations and still no luck. I have run the sql quite a few times in different ways and after the first time it says that this has already been done.
After none of that worked, I tried fixing the files by hand from the notes on this thread, still with no effect.
As for the downloading that many times, it is possible that people are downloading it for a later install which is why I was interested in hearing if anyone else had installed it successfully.
It is very possible that the problem is specific to my cart, so hearing that someone else has installed it and it worked would help me troubleshoot.
I went to the site that you have working and you are right, it works perfectly.
I did notice that when I looked at my cookies that my permlogon from my site imbeds a cookie (which doesn't work) but the other site did not. Curious and baffling. I guess it would help if I was more familiar with how cookies/logon really work.
When I have more time I will try again, I would really like this mod for my someday to be cart. I also really appreciate the work you, crazy_chris and kuroi(and many others) have done.
Pat
@crazy_chris, kuroi, ryk: Kudos and great job to all of you for a fine addition! This is a must-have feature for Zen Cart, IMO, and I'll be pushing the team to include this feature in 1.4. :thumbsup:
To that end I did make some adjustments; just a few issues that would have to be resolved before it would even be considered. I'll send along my revisions shortly, but wanted to let you know the highlights...
- Removed switch for optionally removing the cookie at logoff.
The cookie is now killed at all logoffs. It's assumed that, when a person logs off, they are indeed off. This also presents something of a security issue if the person logs in from a public terminal; if they check the box, you've now removed any ability for them to remove the cookie, aside from manually removing it from the browser.- Added a switch to change the cookie name.
Even though cookies are domain-based, they should always have instance-specific names to avoid any possible naming conflicts (e.g. two stores under the same domain).- Added a switch to change the cookie lifetime.
This is just one of those things that, if you don't have it, someone will ask for it. For a good example of this phenomenon, search the forums for "checkout without account" :blink: . Default time is still 1 year, as you had it.
Hi ryk and all
Well I downloaded whats in 'other' and the contrib works ok for me
Two things
1) If it doesn't work for you, remember that different browsers operate slightly differently when reading instructions to create a cookie. Try a different browser.. works ok on ie6 and firefox for me on my windows pc..
If it gives trouble on a browser, it could the way the browser interprets the cookie path (domain), and if it can't understand it, no cookie gets made.
2) I noticed that starting on home page ('for me') the code which creates the new customer session doesn't tell the page that the session is up and running, presumably because perhaps the session variables are updated after the page has been written.
You can tell this because you still see the 'log in' link at page top, even though the contrib code has made a session and the user has been auto-logged in..
This offering below seems to work, it makes the page refresh after the session is created, so then you get the 'my account' link etc showing as it should, in the site's header.
Find the line with session in as shown, in the index\header_php.php file, add the extra line.
Please note that redirects fail (blank page etc) , if one's got any test 'echo' statements anywhere in the code before it redirects. I guessed the bit with 'zen_get_all_get_params', but it does seem to redirect the page 'back to itself'.
Of course if the customer session didn't get made properly, this system could loop for ever, redirecting.. maybe someone has a fix for that (just in case) if I can't think of one.
Code:$_SESSION['cart']->restore_contents();
zen_redirect( zen_href_link( $_GET['main_page'], zen_get_all_get_params() ) );
(non-coders please skip?)
..and another odd thing happened, I came back to a page which is part of a thing I'm developing, and the time out page came up, ... as it should, because I'd gone away having been auto logged on, but not returned until after the customer session variable had cleared itself.
This is more for the developers really.. currently the time out page asks you to log on, but of course the auto-log on coding (index\header_php.php) has worked, (in my version redirecting, so the 'my account' link is present at top)
...but theres no point in logging on!
The only thing I tried was transferring the whole code block that starts
into the end of init_sessions file, which is well 'above' the index\header_php.php file.Code:if (PERMANENT_LOGIN == 'true' ....
What I got then, (because the session was now correctly sensed as present) in time_out page, is 'sorry you're not allowed to do that' which is a bit more realistic than demanding a log on.
I see the only way to avoid time_out page appearing ever, is to change all the files which call it to suit auto-log on, that's changing all the cart process files - and even if you did that, I bet the current cart session / process would be affected, as the cart presumably has session variables as well..
So... I think its a good idea putting the re-directing auto log on code into the init_sessions file, rather than the index header, at least I don't get led into logging on when I'm already logged on.
Well I'm suitably self-chastised now.. the mods I suggested above did have an effect on the operation of auto log in, but there's possibly something else going on with the way servers process and store changed values in session variables.
(My intuition says, 'they' were not expecting people to change session values then use them immediately for decison making, on the same page?)
What my shared server was doing yesterday, is not what its doing today.. I reckon those that have trouble with auto log in have servers like mine, not consistent.
Or alternatively I'm going bonkers and imagining the whole thing?
I've been testing the standard contrib download with an added 'echo' that displays the session value for customer i.d, just after the auto login code section retrieves the cookie and sets the session value. This using only the first page that the browser displays after a re-start of browser.
.. I'll swear blind that sometimes the session customer i.d is still empty, sometimes it is correct. The rest of the page follows suit, giving a log in page when the echo says the session is empty, and not when the echo says the session has a value.
This appears to happen with any browser, so is it to do with how the server physically updates the session variables that the auto log in code has demanded to be set.
so I'm not being much help in this thread :) am I, other than to say, sometimes the server appears not to obey the order to fill the session with values in time, but its hard to believe it ever happened, after one tests again, and it then starts to work properly for ages without a glitch.
But it does possibly explain why some people are having probs with auto login..
I'm still writing my w.i.p essay here..bear with me..
Have a look at
http://uk.php.net/setcookie
Whether you know php or not, you'll see references low on the page, to the ways different browsers analyze domain names when deciding whether to store a cookie, which in this case is the thing that enables auto logon. There is a vital parameter in the cookie called the domain path.
One prob I have fully examined tonight, is how to get auto login using a domain without the 'www.' in front. Most servers accept 'domain.com' as well as www.domain.com.
One of zencarts quirks is that if the domain gets set to 'domain.com' in the config file, all the pages in zencart have that in the url. This can happen I think when you install, if you initially access your zencart install folder without the www. in front.
But looking at the page quoted above, IE6 especially, it seems that IE6 refuses to store a cookie if there's not two dots in the domain name, if its a dot com. So anyone without the 'www.' in front in the config file, won't ever save a cookie in IE6, for auto logon?
But this isn't the end of the story, as I found out. My IE6 bookmark for my site home page has no www. in front. I proved that when this url is used, the cookie -even if saved properly previously using the contrib's login page with a full www.domain.com, -- the cookie is not read out by IE6 with a page url that has no www. in front. i.e no auto logon.
'for me' IE 6.0.28 sp1, on win 2000 sp2, does not cough up the 'zencart_cookie_permlogin' cookie **previously** saved by a 'www.doman.com' page log in (ticked checkbox), if the page url in the browser address bar **now has** 'domain.com'. Coders can check that out by putting 'echo the cookie value' in php code, near the top of the index page header.
So... woe betide any zencart user that enters the site url without the www. in front, he'll have to manually log on?
I have to be away soon..so can't really go much further at present with this. But it almost seems that cookies for auto logon are a difficult challenge, whereas as far as I know, the only cookie zencart uses is 'zenid', and possibly with a 'non-www.' domain if cookies fail then the server can revert to session variables for zenid, so it doesn't matter...
So the basic problem is, if i'm correct, with certain browsers being awkward about when they will save a cookie, or cough it back up, with the non-www. url page domain base, (or cookie domain) I don't see quite how to ensure auto logon works regardless.
One way would be to redirect any page without www. to the same page with www. in front?
This is not a critique, but if I'm right it needs some mods..
..still enmeshed.....and here's a mod
this is the gobbledegook text from that cookies discussion page I quoted a while back which applies to us unfortunates using .com domains for our zencart,
To avoid the existing auto logon cookie not being saved, or not read later by the browser, because your .com domain without www. has only one dot, but it wants two.......Quote:
'Only hosts within the specified domain can set a cookie for a domain and domains must have at least two (2) or three (3) periods in them to prevent domains of the form: ".com", ".edu", and "va.us". Any domain that fails [sic] within one of the seven special top level domains listed below only require two periods. Any other domain requires at least three. The seven special top level domains are: "COM", "EDU", "NET", "ORG", "GOV", "MIL", and "INT".'
as I said, this happens if the user accesses any cart page **without** the 'www.' in front of the domain name in the url,
this javascript code puts the www. back in front:
To implement this, with dreamweaver or another linux cr/lf editor, put that code into a file calledCode:var URL;
URL = window.location.href;
if(URL.indexOf("www.") < 0){
window.location.href = URL.replace("://","://www.");
}
'jscript_autologin.js'
and save it.
OR get it off my site in zip form
http://www.hareslade.com/zc125/downl..._autologin.zip
Upload the file into your \jscript folder of your current (or default) template.
I'm not sure whether a .co.uk domain for instance also needs a www. to make the cookie available. As already stated, it appears that if the domain url does not have the www., IE6 especially, fails to give the cookie when the autologin text wants to get it, because the browser says a requesting .com domain without a www. is unnacceptable.
======
The above is a non-invasive mod you can add into the auto login contrib.
.coms people and others in the list will notice the home page now comes up correctly as auto logged in, provided of course the log on page was set to auto in the tickbox choice and the cookie was saved.
My javascript knowledge is not immense, but the code seems to work, you see the url change abruptly in the address bar when a non-www. url is used.
..and my final comment is, is obvious but I didn't realise..
If you activate auto login with say IE6, then start using opera instead, you have to do a 'activate auto login' with Opera freshly, because browsers don't use each other's cookies.
That may be why some people think the contrib doesn't work proper..
Hello,
Just installed the Auto Login Mod, and I'm getting the following error at the top of the page. I'd like to find a fix rather than uninstall so any help would be appreciated.
"module_directory('require_languages.php')); // set the product filters according to selected product type $typefilter = 'default'; if (isset($_GET['typefilter'])) $typefilter = $_GET['typefilter']; require(DIR_WS_INCLUDES . zen_get_index_filters_directory($typefilter . '_filter.php')); // query the database based on the selected filters $listing = $db->Execute($listing_sql); // if only one product in this category, go directly to the product page, instead of displaying a link to just one item: // if filter_id exists the 1 product redirect is ignored if (SKIP_SINGLE_PRODUCT_CATEGORIES=='True' and (!isset($_GET['filter_id']) and !isset($_GET['alpha_filter']))) { if ($listing->RecordCount() == 1) { zen_redirect(zen_href_link(zen_get_info_page($listing->fields['products_id']), ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing->fields['products_id'])); } } // This should be last line of the script: $zco_notifier->notify('NOTIFY_HEADER_END_INDEX'); ?>"
Thanks
autologin revisited..
I think the log out page is not always working, the cookie is not being deleted.
This can be tested by initialising autologon, convince yourself it works.
Then log off, close the browser, (and all other browser windows of the same browser), then come back to the cart home page with the same browser.
If the cookie really was deleted, you'll be asked to log on when you return.
If it logs you on then obviously the cookie is still existing.
I reckon the cookie set code in logoff\header_php.php is incomplete, see below.
Without a path set to same path (/) as the original cookie, I can see why a logoff might not destroy the cookie.
Certainly only the modified code seems to correctly work in firefox.
Code:Existing code was similar to:
setcookie("zencart_cookie_permlogin", "expired", time() - 3600);
Modify to:
setcookie("zencart_cookie_permlogin", "expired", time() - 3600, '/', $current_domain);
The mod does NOT keep me logged in as promised. Im IE7 and all files have been processed correctly.
www.theribbondiva.com
studeo
try firefox or netscape browsers
check that the login cookie is saved with Ie7 (presumably theres a way)
Im sorry to say that it is not effective in Firefox either. I will recheck my files but I believe I install all correctly.
More info:
I stay logged in as long as the browser is open. If I close and go back to the site, no login. I re-upped all files again just in case, but same non-results.
Any advice?
PS: If we can make this work, there is a bold NB: at the beginning of the check box line I would like to edit. Which file would that be in?
Thanks
With 1024 downloads since being posted and only a handful of problems reported, then I'd suggest it's more likely something to do with your installation rather than the mod itself.
Thats why I came here for help. This is such an easy mod that needs no hand coding. So I installed it again. Still no luck.
What should the cookie say or look like? Perhaps its not even being written, but I do get a cookie from the site at the same time I login.....Im happy that 1023 people have this working....Im no coder but the instructions are very easy....I just came here looking for help.
Is it possible this only works for new user accounts?
Sorry - I can't help. I'm no coder either - I merely packaged up the work of others to make installation easy.
Studio, do some detective work... Using firefox.. its all about wheher a cookie got saved in your computer..
Make a new user for zencart, check the 'permanent login' box when you register.
This should create the cookie in your firefox cookie browsers list once processed.
Then in firefox go to:
Tools | options | privacy | click view cookies button,
locate a cookie name similar to 'zencart_cookie_permlogin' ...... if its not there, it won't be possible to be auto logged on later
Cookie 'Content' should be a load of characters long
Cookie 'Domain' will probably be your website without the www, but a dot in front.
Your computer might also be not accepting cookies, there are setup settings for that for each browser. I have the 'allow sites to set cookies' checkbox checked in my firefox (see cookie lists window area).
Difficult to guess further..
There is a cookie placed from the domain (with no period at the front) but nothing that says zencart_cookie_permalogin. I suppose this is not going to work for me. Does this mean it wont work for anyone else from my site?
thanks to those who tried to help...I have since replaced the modded files with the originals and I will leave it as it is.
studeo
Could this have something to do with my server's setting?
PS I really don't want to give up on this.!
studeo ........... well ...... either you make it work, or you give up :)
p.m me with the cart url if its web, I can see then if indeed the cookie gets received at all
I'm also having problems getting this working. We've tried IE6 & Firefox on PCs, and Safari & Firefox on macs.
I have a zencart_cookie_permalogin cookie. It's got:
Content: big long string, mostly %7E
Host: my domain with www, but no preceding dot.
Path: correct path to shop below Host
Send for: any type of connection
Expires: tomorrow
Any ideas?
I seem to remember it (the cookie) doesn't work if your page url doesn't have the www. in front.
Delete the cookie, run again with www. in the url for the site. Sometimes the config for zen gets set without the www. in front, so all your own zen pages are running without www. at your end. The config file entries for your domain can be corrected for zencart manually.
Otherwise, thats why somewhere here I did that jscript, to relocate any non-www page to the better formed www. page. You can also do it with a htaccess I think.
Hope this helps rather than hinders!
Aha! Thanks. I added added some mod_rewrite lines to .htaccess (below) and it seems to be working. Thanks!
Code:RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
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.
if it works.. its great :)
I had the same problems with this as studeo has. I messed around with the settings and found that if:
1.) Under Configuration > Customer Details > Customer Shop Status is set to "1= Must login to browse" this mod does not work, any other setting seems to work fine however.
2.) Under Configuration > Customer Details > Customer Approval Status is set to "1= Must be Authorized to Browse" this mod does not work, any other setting seems to work fine however.
Is there perhaps a work-around for this in order to get this cool mod working with the abovementioned settings enabled?
Thanks!
Excuse the bump, any ideas regarding what code has to change in order to get this working with aforementioned settings enabled?
Well, I've tried to get this module installed and working, but I couldn't get it to autologin. But after reading this thread 3 times I believe I figured out my problem. The site I'm installing it on used a share ssl certificate. So the domain name for the login screen is different then the main domain.
Once I used the shared cert domain and path I was logged in automatically.
So is there a way to have the autologin work on the login page instead of the index page? So the domain matches the cookie?
Thanks for the tip b00n. Just for anyone else I found the autologin code seemed to work best when placed at the bottom of the file application_top.php - had some issues with it being at the very top of the file.
I have installed this Version of the Module:
Author: Linxor
Version: 1.3
Zen Cart™ Version: v1.3.8
Update added on Nov 06 2009
The Problem I have: Going to Admin > Configuration > Customer Details I loaded the "Automatic Login (days to remember)".
But there, I can't set the days but "true" or "false".
So, this sql-patch is not correct:
How do I get a input-field for days rather than "true/false"?Code:insert into `configuration` (`configuration_id`,`configuration_title`,`configuration_key`,`configuration_value`,`configuration_description`,`configuration_group_id`,`sort_order`,`last_modified`,`date_added`,`use_function`,`set_function`) values ( NULL,'Automatic Login (days to remember)','PERMANENT_LOGIN_EXPIRES',14,'Automatic Login - Number of days to remember the user','5','102',NULL,now(),NULL,'zen_cfg_select_option(array("true", "false"), ');
I installed this mod successfully. I would like to add an additional feature on the login header. If customer logged in already, i would like to display customer's first and last name follow by [Logout]. This is very similar to Welcome message on the main page, except for i would like to have it display on the header file. The benefit of it is to let customer know that his session is still active. How do i accomplish this?
In file, /includes/languages/english/MYTEMPLATE/header.php
I changed define('HEADER_TITLE_LOGOFF', '[Log Out]');
to
define('HEADER_TITLE_LOGOFF', %s[Log Out]');
The display result shows the same. What is the actual variable to represent current user's first and last name?
i also can't get this mod work out.
i have checked code many times
but i can't seek any cookie should be generated.
how can debug it.
i am not a coder.
anybody can help?
also the configuration of days not work, to be true/false option.
I want to uninstall this module and clear the data from the database. Anybody can help??? Thanks a lot!
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);
}
?>
Hey there,
Thanks, this was helpful. The only problem is, I found it was creating multiple cookies for different paths since it is placed in the application_top file. To fix this, just set the path (and optionally the domain) when you send the cookie.
Make sure you set your logoff header to match.PHP Code:
setcookie("zencart_cookie_permlogin", $c_str, time() + $timeout, "/", ".yoursite.com");
Everything is working perfectly after fixing that.PHP Code:
setcookie("zencart_cookie_permlogin", "expired", time() - 3600, "/", ".yoursite.com");
Hi all
I also use the cited version. Quoted sql-patch is correct. This module works well in my store (1.3.9h)
I stick PERMANENT_LOGIN_EXPIRES in includes/modules/pages/login/header.php:
PHP Code:
// AutomaticLogin module: Allow the user to be automatically logged in. -//
if (!empty($_REQUEST["permLogin"])) {
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[] = $check_customer->fields['customers_password'];
$c_str = implode("~~~", $c);
$timeout = 86400 * PERMANENT_LOGIN_EXPIRES; // Change the last number here to the number of days the user should stay logged in
setcookie("zencart_cookie_permlogin", $c_str, time() + $timeout, "/", ".example.com");
}
Before setting this:
log into Your database (via phpMyAdmin),
open "configuration" table ,
search in "configuration_key" PERMANENT_LOGIN_EXPIRES variable,
click "change",
get into "set_function" field and replace:
withPHP Code:
zen_cfg_select_option(array("true", "false"),
That's all - now in Admin You can set the number of days the user should stay logged in. Get: Configuration Menu - Customer Details - Automatic Login (days to remember)PHP Code:
zen_cfg_textarea_small(
Automatic login is very necessary to professionalise the shop module, thank you very much for all of its creators. Good job!
My test site :http://ximap.pl/www/
Zen Cart zen-cart-v1.3.9h-full-fileset-10262010
Mounted mods, all tested and working well in 139h ZC:
- about_us_page_1-3-1
- admin_login_as_customer_2-2
- admin_profiles_1-1-1
- attrib_image_module139h (by my additions)
- ask_a_question_1-3-9h (by my additions)
- AutomaticLogin-1.3.9h (by my additions)
- CRON for Easy Populate 1.2.5.5 (by me and others)
- css_javascript_loader
- Easy Populate 1.2.5.5
- image_handler 2
- product_filter_module_for_zencart_2 (by me and others)
- save_your_sideboxes_layout_as_the_default_1-11
- questions_and_answers_page_1-3-1 (based on about_us_page_1-3-1)
- search_log_2-0
- search_configuration_keys_1-3
- search_helper_1-0a
- search_instock_products_only_1-0
- single_listing_template_1-8
- sms_on_sale_1.1a
Uff :lamo:
A small note on my test website:
Often on this site is testing new solution, so do not be surprised if you see something wrong - this is normal when web page is in debug mode :cool:
Here is the corrected version of the perm-login.sql file to run so that when you edit the 'number of days to remember', instead of getting True or False, you will be able to change the number of days.
I combined the fix from alsprog into the sql patch file on the addon download perm_login.sql to add the module to my live site and it worked.
Attachment 9349
I wanted to add this to the Addon Download for this module, but didn't know how.
Thanks to all you guys who developed this. I am very grateful. I just wish I had read the posts from the back before I tried implementing everything step-by-step and then eventually discovered that there was a download available. But it all works really nicely now.
I've just submitted v1.4.0 to the Plugins, available for download here once reviewed: http://www.zen-cart.com/downloads.php?do=file&id=332.
This version has been verified on Zen Cart versions 1.5.0 through 1.5.2 and provides the following changes:
- Incorporate SQL install script into a PHP auto-install script.
- Move run-time language changes into an extra_definitions file so that they're common between the login and create_account page.
- Move processing to a run-time observer, no more core-file overwrites!
- Modified information stored in the cookie and the means of validating the cookie's value.
- Removed customer logoff as an option (for simplification); if the customer chooses to logoff from the store, the "Remember Me" cookie expires.
v1.4.0 is now available for download.
Hi,
What if we log off and still the cookie does not expire.
We do see the log off page, but we are not able to see the Login Page and the Login Link directly logs us in unless we delete the cookies.
What could be wrong ?
Thanks
I'll take a look and report back in a bit ... is there a specific site? If you don't want to post it here, let me know via PM.
Did you change the default cookie lifetime after installation (Configuration->Customer Details->Automatic Login (Cookie Lifetime))? It defaults to 14 days.
Hi,
I just upgraded our website and Automatic login module.
In the Customer Details--->Automatic Login (days to remember) I see option for True and False instead of a place to enter the number of days.
Which file can I check or replace to get the number of days option as a text box ?
Thank you very much
Go to your admin's Tools->Install SQL Patches and enter the following to remove the configuration setting. It'll be re-instated with the default of 14 on the next admin-page refresh.
Code:DELETE FROM configuration WHERE configuration_key = 'PERMANENT_LOGIN_EXPIRES' LIMIT 1;
Done.
I can see 14 days now.
But still cannot log off .
What can I check ?
I have Pm'ed you our website.
Thanks
I created an account, logged off, logged back in (ticking the "remember me" box), verified that the cookie (14 day life-span) had been created, logged off and verified that the cookie had been deleted.
I'm guessing that the issue you're seeing has to do with the fact that the plugin's configuration was messed; just delete that cookie and you should be good-to-go.
You may be able to see the log off page, however try getting to the login page again where say you want to login using another email id,
I am not able to see that page.
I deleted all cookies and tried the same.
There was a cookie named (something like) zencart_permanent_login that, when deleted, restored the login/create-account page. That cookie is not part of this plugin.
When I do not click the "Check Box" to remember the account, the login and logout page functions fine.
When I check it, the issue of not getting to the login page occurs.
This checkbox is a part of the plug-in hence am wondering what else could be.
Also when I disable this module from Customer Details, the login page is visible.
There is no other contribution for this function too.
What more could we look into ?
You should use your admin's Tools->Developers Tool Kit to search for zencart_cookie_permlogin to identify which module is forcing this login.
Thanks, this issue is solved, I deleted all the older traces of this module from the header_php.php page.
A new issue I face is, when one clicks on "Log In" from the Homepage and after logging in the page gets back to the homepage, the link on top still shows as "Log In" instead of "Log Out"
When we go to any other page after this, we get automatically logged in.
What can we check.
Setting the value of "Automatic Login (days to remember)" to 0 does solve this issue.
However want the cookie to remember customer login for aleast 30 days
What does 0 mean ? is this like remember for ever till cookie is not cleared ?
I suggest that you download v1.3.8 of the plugin (https://www.zen-cart.com/downloads.php?do=file&id=332) and, using a file-comparison tool like Beyond Compare or WinMerge, remove all remnants of the previous version.
I've submitted v1.4.2 to the plugins for review:
- Include a SQL uninstall script
- Update template-override files to use ZC 1.5.5 as their change-basis.
v1.4.2 is now available for download: https://www.zen-cart.com/downloads.php?do=file&id=332