![]() |
Making it so they don't have to re-login everytime
I have some visitors complaining about having to re-login everytime they come back.
How difficult is it to keep them logged in until they log out. Maybe set a cookie that gets read upon return and creates the session? |
Sorry i can not help you with a solution, but i would be verry carefull
with this. What happens if somebody stays logged in at the office or such? Especially when you store creditcard information it can lead to verry unpleasant situations. Who will be responsible if other people start bying on his account? Cheers Eddie |
Yup, I understand the possible ramifications.
I NEVER store credit card information on my records, I just don't want that responsibility, and the user takes responsibility for their account in our terms of service. :wink: |
If you change inlcude/check_useraccount.php: from
Code:
session_register("login"); to Code:
session_set_cookie_params(15552000); That will save their session for 6 months - but I would warn against it for all the same reasons as highlighted. |
Would it be possible to add a check box next to the login box
[X] Remember my Password ? |
That's a good idea, and then maybe have a javascript popup warning when they check it.
I'll work on this tonight and see what I can come up with, don't see why it wouldn't be doable. |
Cool!!! Keep us updated on your progress. Something like that would be very usefull!
|
yeah, that sounds really good, if you get the code for it, please share :)
|
session_set_cookie_params(15552000);
Adding that does not seem to work to keep sessions. I can do the logistics of the checkbox, and what not, but I'm having difficulty getting it to set the extended cookie, and I need to do that first. :) |
Quote:
Definitely doesn't work, any other thoughts? |
My assumption is that you need to set a seperate cookie, and then read from that cookie to start a new session when they return.
|
Ok. So we set a cookie:
Create a sub-folder in the Modules folder called: Save_Login Create a file in the sub-folder called: set_cookie.php and put this code in it: Code:
// Set cookie with login name Then open /include/login.php and find this code: Code:
db_query("update $sql_tbl[customers] set last_login='".time()."' where login='$login'"); AFTER that put: Code:
# If the person is a customer, they now have a LoginCookie set under the domain name containing "username" and "logintype" where C is the userlevel, set to expire in 6 months. Now we need to read from that cookie. (I'm documenting the process but don't believe this code to be correct until the process is finished). |
Looks like there's some protection in check_useraccount.php against faking cookies or session variables:
Code:
if ($HTTP_POST_VARS["login"] || $HTTP_GET_VARS["login"] || $HTTP_COOKIE_VARS["login"] || $HTTP_POST_VARS["login_type"] || $HTTP_GET_VARS["login_type"] || $HTTP_COOKIE_VARS["login_type"]) { Please be encourage to make this monologue a dialogue ;) |
Got it to work, will post full modification for feedback, criticism and security checks shortly.
|
Here's what's needed. I'm using I beleive 3.2.2, not positive on that.
Create a sub-folder in the Modules folder called: Save_Login Create a file in the sub-folder called: set_cookie.php and put this code in it: Code:
<? Create another file in that subfolder called: reset_cookie.php with this code in it: Code:
<? Open include/check_useraccount.php and change to look like this: Code:
<? Open up /include/login.php and find where it says this: Code:
# 1) generate $last_login by current timestamp and update database AFTER that, add this: Code:
# Also in include/login.php find this: Code:
if($mode=="logout") { AFTER that add: Code:
include "../modules/Save_Login/reset_cookie.php"; Open up skin1/auth.tpl (Note: I believe I've made some slight changes to this file, maybe just adding the "navlink" class). File should look similar to this: Code:
{* $Id: auth.tpl,v 1.19 2002/09/10 12:36:33 zorg Exp $ *} |
I'm by no means a programming expert, anybody see any security flaws.
There might be an issue with being able to fake cookies. |
Been watching your posts for a while now. I haven't dissected the code yet, but regardless of the outcome - kudos on the work.
|
Thanks. I plan on creating a new reality TV show: The making of an automatic login script :P
Definitely a cookies issue here, password will likely need to be written to a cookie and verified as well, however that could create a security issue in that the password can be pulled from the cookie. |
Quote:
Oh yeah? I heard FOX was going to produce it |
Naturally.
|
Quote:
If that's true it means you gotta encrypt the password - ugh. |
Got that worked out.
The crypted password is stored as a variable, so I stored it in a cookie. I then included the login, logintype, and password to query the database. Since the password in the database is crypted, I didn't have to decrypt it. If the query returns null, the person is not logged in. Changes to previous code: reset_cookie.php Code:
<? set_cookie.php Code:
<? include/check_useraccount.php Code:
$LoginCookie = $_COOKIE['LoginCookie']; |
This is definitely a worthy mod. Can someone bump this to the Custom Templates. Also, have you check to see if this works after implementation? I would like to use this, but don't want to risk hacking my site to screw something else up. Thanks for you hard work and for posting it. :)
Chris |
I installed this and it seemed to work just great.
Actually it worked perfect! But, our worst dreams have come true. There is a major security flaw. If you go on the website and login and then go to /admin you are logged in as admin as a normal user. From there I was able to access admin functions and look at orders, make product changes... Not good! ACK! |
Sorry, i did find that error in my beta testing but didn't think to post up the fix.
I believe I fixed this by adding current_area to my check_useraccount.php Code:
<? |
^^ The last part of that code I use to change the welcome back message, as I didn't want to greet them by their login name. Instead: Welcome back, firstname lastname!
If you want to use that as well, you can edit your authbox.tpl to use: Code:
Welcome back, |
I believe that takes care of everything. If anybody sees anything else, please let me know asap.
|
I tried this feature, and I followed every step, including the updates for security, and this is what happened
Code:
Warning: Failed opening '../modules/Save_Login/set_cookie.php' for inclusion (include_path='.;c:\php4\pear') in W:\www-toonarific\xcart\include\login.php on line 80 I reverted back to the normal state until this error goes away. Any help is greatly appreciated. |
nevermind. I found my error
|
One major bug I found
if a customer doesn't check the box, no matter how many times they try and login, it doesnt recognize them. only after they check the box does the store realize they want to log in
|
and is there a way to only have the 'remember me' check box appear on the customer's home page, and not the admin page?
|
Re: One major bug I found
Quote:
I haven't had this problem. |
Quote:
I have my admin section on a secure url, so I have seperate auth.tpl's. You could probably just edit your auth.tpl with something like this: Code:
{if $redirect ne "admin"} |
I just tried that. It does make the checkbox go away, but then when I try to login I get a cgi error. Also, I noticed that after I login with the checkbox, the only way it recoginzes when I logout is when I completely close the browser and reopen it.
|
I'm sure you've made errors in your coding.
I don't know how you get a cgi error when your working with php ?!? |
Nice work, Jon.
I haven't looked at your code thoroughly, but right off the bat I'll give you some advice. The proper, secure way to store logins is to use sessions. The only thing you store on the user's machine is a cookie with the SESSIONID. When that cookie expires, the user is logged out. You then store the username/password in the session that matches the SESSIONID in the cookie. This way you don't need to work about encryption or any reverse engineering on the crypt method by a session hijacker. Ideally, Xcart should leave the user logged in forever, but then authenticate if the user goes into sensitive areas like Checkout, Modify Profile, Modify Credit Card, etc. This is how most large sites do it (e.g. Amazon). |
X-Cart does use sessions to store auth info. Sessions generally expire. That's the point of all this cookie talk. Nobody wants to store inactive sessions in their database for months on end.
|
Hmm, I had this working on 3.4.14 but can't get it to work on 3.5.x, anyone else have any luck using this for 3.5.x? If you did, can you please paste your code for login.php, check_useraccount.php and auth.tpl?
Thanks |
Jon: I am anxious to try this mod, but I have 2 things I want to discuss first.
1: Does it work woth 4.0.X? 2: Can you please repost in a single post, all the codes needed to be changed? I tried to follow along, but there are fixes for fixes posted later in the thread. An all-in-one reply would be great, so we can just follow along in a single post rather than jumping all around. And hey, thanks for the awesome job. People like you keep this place alive. |
I don't know what versions it will work on, likely it would need adaptation for the 3.5.x and 4.0.x versions. I don't have time to work on this.
Jon |
All times are GMT -8. The time now is 06:00 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.