X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Keeping the users loged in and keep anonimous users cart content (https://forum.x-cart.com/showthread.php?t=39395)

virtual@croatia 04-28-2008 01:51 AM

Keeping the users loged in and keep anonimous users cart content
 
Problem:

How to keep users logged in and anonymous users to keep cart and wishlist contents.

In auth.php find the line
PHP Code:

include_once $xcart_dir."/init.php"


and replace it with...
PHP Code:

#
# If the user has been here in the last 6 month, extract the session ID from a cookie
#
if (!empty($HTTP_COOKIE_VARS["xsessionid"]))
    
$HTTP_POST_VARS["xid"] = $HTTP_COOKIE_VARS["xsessionid"];

include_once 
$xcart_dir."/init.php";

#
# Keep user session ID in a cookie for 6 months
#
if ((empty($HTTP_COOKIE_VARS["xsessionid"]) && !empty($XCARTSESSID)) || $HTTP_COOKIE_VARS["xsessionid"] != $XCARTSESSID)
    @
setcookie("xsessionid"$XCARTSESSIDtime()+3600*24*180); 



in config.php find the line
PHP Code:

$use_session_length 3600

and replace with the line which will extend keeping session data (cart contents, wishlist contents etc.) for 6 months
PHP Code:

$use_session_length 180*24*3600



in modules\Users_online\registered_user.php find the line
PHP Code:

$expiry_time $curtime $config["Sessions"]["session_length"]; 

and change it with the line which will decrease the counter of the online users to only those users which were active in the last 5 minutes (300 seconds):
PHP Code:

$expiry_time $curtime 300



This should keep the user session id for 6 months and everyone who has been logged in will be remembered during that period. What is even more important, anonymous users cart will stay remain.

Important:
Please try it on a test server before you implement it!

imexhouse 04-28-2008 07:54 AM

Re: Keeping the users loged in and keep anonimous users cart content
 
virtual,

How would I test it? 6 months is a long time :)

virtual@croatia 04-28-2008 08:02 AM

Re: Keeping the users loged in and keep anonimous users cart content
 
Quote:

Originally Posted by imexhouse
virtual,

How would I test it? 6 months is a long time :)


:-) Yes, it is. I'm using it currently on line on www.smee.hr and it seams it works. You can try it there. Try to put some products in a cart, close the browser and open it again. I think it works, but you never know where can be a bug.

cflsystems 04-28-2008 08:21 AM

Re: Keeping the users loged in and keep anonimous users cart content
 
If you use different browser if won't keep the info there. Not sure if this can qualify as a bug.

imexhouse 04-28-2008 08:22 AM

Re: Keeping the users loged in and keep anonimous users cart content
 
Well, so far so good.
I'll return in a couple of days and see if my cart has still products in it.
By the way, nice site :)

imexhouse 04-28-2008 08:23 AM

Re: Keeping the users loged in and keep anonimous users cart content
 
I don't think it's a bug. Each browser creates its own cookies, doesn't it?

virtual@croatia 04-28-2008 08:29 AM

Re: Keeping the users loged in and keep anonimous users cart content
 
Quote:

Originally Posted by imexhouse
I don't think it's a bug. Each browser creates its own cookies, doesn't it?


That's right. You can't do anything here.

cflsystems 04-28-2008 09:50 AM

Re: Keeping the users loged in and keep anonimous users cart content
 
Nevr mind then. I was thinking the browsers share the cookies, same format and read them from one location. Everyday learn something new.

imexhouse 04-28-2008 02:09 PM

Re: Keeping the users loged in and keep anonimous users cart content
 
I have returned to http://www.smee.hr after several hours and, unfortunately, my cart is empty.
I'll give it another try.
Also, this line:

Quote:


$config["Sessions"]["session_length"] = 60*24*3600;


sets the session length for 2 months, not 6. Is that what you wanted?

imexhouse 04-28-2008 04:38 PM

Re: Keeping the users loged in and keep anonimous users cart content
 
Once again, after 2:30 hours, I returned to your store, virtual@croatia, but the cart is empty again.

virtual@croatia 04-29-2008 05:14 AM

Re: Keeping the users loged in and keep anonimous users cart content
 
Quote:

Originally Posted by imexhouse
I have returned to http://www.smee.hr after several hours and, unfortunately, my cart is empty.



Well, it seams we've found another error. I'll check it.

Quote:

Originally Posted by imexhouse
Also, this line:

sets the session length for 2 months, not 6. Is that what you wanted?


Nop :-). My mistake.

imexhouse 04-29-2008 11:42 AM

Re: Keeping the users loged in and keep anonimous users cart content
 
I registered and added a product to my shopping cart. Then, left and returned after a couple of hours. Logged in and the ordered product is still in my cart.
So, logged in users will retain the cart contents, but anonymous users won't, from what I can tell so far.

virtual@croatia 04-29-2008 12:45 PM

Re: Keeping the users loged in and keep anonimous users cart content
 
Quote:

Originally Posted by imexhouse
I registered and added a product to my shopping cart. Then, left and returned after a couple of hours. Logged in and the ordered product is still in my cart.
So, logged in users will retain the cart contents, but anonymous users won't, from what I can tell so far.


I've found another problem, very importnant. When you move to the secure pages, you loose your cart contents. So, don't use until I find the solution.

imexhouse 04-29-2008 12:48 PM

Re: Keeping the users loged in and keep anonimous users cart content
 
virtual - when I move to what pages? I'm not sure I understand...

kube 04-29-2008 02:20 PM

Re: Keeping the users loged in and keep anonimous users cart content
 
I think he may mean moving over to https.

sucer pages maybe a typo for secure pages.

imexhouse 04-29-2008 03:10 PM

Re: Keeping the users loged in and keep anonimous users cart content
 
Of course..
Thx

virtual@croatia 04-29-2008 08:32 PM

Re: Keeping the users loged in and keep anonimous users cart content
 
Quote:

Originally Posted by kube
I think he may mean moving over to https.

sucer pages maybe a typo for secure pages.


:-) Yup, that was it.

virtual@croatia 04-30-2008 02:07 AM

Re: Keeping the users loged in and keep anonimous users cart content
 
I'm doing on it right now and I will report all changes in the first post, so you can keep track there.

virtual@croatia 04-30-2008 03:24 AM

Re: Keeping the users loged in and keep anonimous users cart content
 
I think that with the changes I made it works now. Please try it on a test server before implementation, but I think it's OK now. You can also try it on my web site www.smee.hr where I've already implemented it.

imexhouse 04-30-2008 03:30 AM

Re: Keeping the users loged in and keep anonimous users cart content
 
Yeah, but where's the code?
:)

virtual@croatia 04-30-2008 03:33 AM

Re: Keeping the users loged in and keep anonimous users cart content
 
Quote:

Originally Posted by imexhouse
Yeah, but where's the code?
:)


In the first post (top of the thread).

imexhouse 04-30-2008 03:50 AM

Re: Keeping the users loged in and keep anonimous users cart content
 
You mean you edited the original post?
The one that didn't work?
I just want to make sure...

imexhouse 04-30-2008 03:54 AM

Re: Keeping the users loged in and keep anonimous users cart content
 
In my config.php (4.0.19) I have:

$config["Sessions"]["session_length"] instead of $use_session_length

Anyway, I added some stuff to the cart on smee and left. We'll see later on today..

virtual@croatia 04-30-2008 05:32 AM

Re: Keeping the users loged in and keep anonimous users cart content
 
Quote:

Originally Posted by imexhouse
You mean you edited the original post?
The one that didn't work?
I just want to make sure...


Yes, the original one. I edited it, it's better to keep changes at the top of the thread.

virtual@croatia 04-30-2008 05:40 AM

Re: Keeping the users loged in and keep anonimous users cart content
 
Quote:

Originally Posted by imexhouse
In my config.php (4.0.19) I have:

$config["Sessions"]["session_length"] instead of $use_session_length

That's the same. In 4.1.x is $use_session_length, but in an another file is a line with $config["Sessions"]["session_length"] = $use_session_length

Quote:

Originally Posted by imexhouse
Anyway, I added some stuff to the cart on smee and left. We'll see later on today..


I think it works, cause the table xcart_sessions_data in which are all sessions data variables (cart contents, login name etc.) is growing. This table will have exactly the same amount of rows as are unique users in 6 months plus robots, so it will be quite a big table :-).

imexhouse 04-30-2008 07:29 AM

Re: Keeping the users loged in and keep anonimous users cart content
 
Well, I just returned to your store and the cart is full!
Good job!

virtual@croatia 04-30-2008 07:32 AM

Re: Keeping the users loged in and keep anonimous users cart content
 
Quote:

Originally Posted by imexhouse
Well, I just returned to your store and the cart is full!
Good job!


:-) Thanks. I hope it will stay full for 6 months :-). You can try my wishlist as well. I made it to accept anonymous users (usually you have to log in to use it) and it should keep it for 6 months as well.

imexhouse 04-30-2008 02:41 PM

Re: Keeping the users loged in and keep anonimous users cart content
 
I think the line in modules/Users_online/registered_users.php:

$expiry_time = $curtime + 300;

is ignored, if you set the session expired time in config.php to something else.

I have registered_users.php set for 5 minutes, but my users online stats are still showing users that visited my site 12 hours ago.

virtual@croatia 05-01-2008 01:06 AM

Re: Keeping the users loged in and keep anonimous users cart content
 
Quote:

Originally Posted by imexhouse
I think the line in modules/Users_online/registered_users.php:

$expiry_time = $curtime + 300;

is ignored, if you set the session expired time in config.php to something else.

I have registered_users.php set for 5 minutes, but my users online stats are still showing users that visited my site 12 hours ago.


I think you are right. I'll check tomorrow what is going on with it and send the correction.

imexhouse 05-01-2008 01:26 AM

Re: Keeping the users loged in and keep anonimous users cart content
 
Another possibility is that all the users that visited my website before I made the change to 300 seconds (from 6 months), had their sessions registered already and changing the expiry period to 300 wouldn't affect them, but would only apply to new users.

virtual@croatia 05-01-2008 11:36 AM

Re: Keeping the users loged in and keep anonimous users cart content
 
Quote:

Originally Posted by imexhouse
Another possibility is that all the users that visited my website before I made the change to 300 seconds (from 6 months), had their sessions registered already and changing the expiry period to 300 wouldn't affect them, but would only apply to new users.


Just go to the php MyAdmin, find the table xcart_users_online and empty it (DON'T DROP IT, just empty it!). It will be filled how the users are browsnig through the web site.

imexhouse 05-01-2008 02:22 PM

Re: Keeping the users loged in and keep anonimous users cart content
 
That's exactly what I did. Thanks :)

Jeremy Smith 06-08-2009 03:12 AM

Re: Keeping the users loged in and keep anonimous users cart content
 
Sorry this may sound stupid (I do apologise about the other post http://forum.x-cart.com/showthread.php?t=47977 can one of the mods remove it please? thanks).

What I was wanting on our X Cart, is for the user to login, their session lasts for 10minutes, when that time frame expires, X Cart looses whats in their cart so they have to add them to their cart again.

I know this could be annoying for some users, but the reason we have to do this, is due to our prices changing and quantity's changing, our direct product feed from our supplier is downloaded onto a workstation processed and then uploaded every hour.

This would seem weird for a user to see the stock levels going up or down depending on the time of day, the main reason we need this feature.

Is it possible to do this?

Thanks ever so much,
Jeremy.


All times are GMT -8. The time now is 10:14 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.