Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Keeping the users loged in and keep anonimous users cart content

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 04-28-2008, 01:51 AM
 
virtual@croatia virtual@croatia is offline
 

Advanced Member
  
Join Date: May 2007
Posts: 92
 

Default 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!
__________________
Check what you can do with x-cart 4.1.9:
www.smee.com

Modules I made:
IP_Ranges
Multy_Currency
Order_Dates

Modules I use:
Fancycategory
Magnifier
Survey
AOM
Reply With Quote
  #2  
Old 04-28-2008, 07:54 AM
  imexhouse's Avatar 
imexhouse imexhouse is offline
 

eXpert
  
Join Date: May 2006
Location: Canada
Posts: 377
 

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

virtual,

How would I test it? 6 months is a long time
__________________
Jack@AquasanaCA
X-CART GOLD 4.0.19 Live
DSEFU, AOM, ezCheckout, ezUpsell, ezRecommends, RememberMe, RememberAnonCarts
AquasanaCanada.com - Aquasana╝ - #1 Rated Water Filters in America!
X-CART GOLD 4.4.5 Live
CDSEO Pro v. 1.8.4
AquasanaMontreal.com
Aquasana╝ & Rhino Water Filtration Systems
Reply With Quote
  #3  
Old 04-28-2008, 08:02 AM
 
virtual@croatia virtual@croatia is offline
 

Advanced Member
  
Join Date: May 2007
Posts: 92
 

Default 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.
__________________
Check what you can do with x-cart 4.1.9:
www.smee.com

Modules I made:
IP_Ranges
Multy_Currency
Order_Dates

Modules I use:
Fancycategory
Magnifier
Survey
AOM
Reply With Quote
  #4  
Old 04-28-2008, 08:21 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,190
 

Default 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.
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #5  
Old 04-28-2008, 08:22 AM
  imexhouse's Avatar 
imexhouse imexhouse is offline
 

eXpert
  
Join Date: May 2006
Location: Canada
Posts: 377
 

Default 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
__________________
Jack@AquasanaCA
X-CART GOLD 4.0.19 Live
DSEFU, AOM, ezCheckout, ezUpsell, ezRecommends, RememberMe, RememberAnonCarts
AquasanaCanada.com - Aquasana╝ - #1 Rated Water Filters in America!
X-CART GOLD 4.4.5 Live
CDSEO Pro v. 1.8.4
AquasanaMontreal.com
Aquasana╝ & Rhino Water Filtration Systems
Reply With Quote
  #6  
Old 04-28-2008, 08:23 AM
  imexhouse's Avatar 
imexhouse imexhouse is offline
 

eXpert
  
Join Date: May 2006
Location: Canada
Posts: 377
 

Default 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?
__________________
Jack@AquasanaCA
X-CART GOLD 4.0.19 Live
DSEFU, AOM, ezCheckout, ezUpsell, ezRecommends, RememberMe, RememberAnonCarts
AquasanaCanada.com - Aquasana╝ - #1 Rated Water Filters in America!
X-CART GOLD 4.4.5 Live
CDSEO Pro v. 1.8.4
AquasanaMontreal.com
Aquasana╝ & Rhino Water Filtration Systems
Reply With Quote
  #7  
Old 04-28-2008, 08:29 AM
 
virtual@croatia virtual@croatia is offline
 

Advanced Member
  
Join Date: May 2007
Posts: 92
 

Default 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.
__________________
Check what you can do with x-cart 4.1.9:
www.smee.com

Modules I made:
IP_Ranges
Multy_Currency
Order_Dates

Modules I use:
Fancycategory
Magnifier
Survey
AOM
Reply With Quote
  #8  
Old 04-28-2008, 09:50 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,190
 

Default 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.
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #9  
Old 04-28-2008, 02:09 PM
  imexhouse's Avatar 
imexhouse imexhouse is offline
 

eXpert
  
Join Date: May 2006
Location: Canada
Posts: 377
 

Default 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?
__________________
Jack@AquasanaCA
X-CART GOLD 4.0.19 Live
DSEFU, AOM, ezCheckout, ezUpsell, ezRecommends, RememberMe, RememberAnonCarts
AquasanaCanada.com - Aquasana╝ - #1 Rated Water Filters in America!
X-CART GOLD 4.4.5 Live
CDSEO Pro v. 1.8.4
AquasanaMontreal.com
Aquasana╝ & Rhino Water Filtration Systems
Reply With Quote
  #10  
Old 04-28-2008, 04:38 PM
  imexhouse's Avatar 
imexhouse imexhouse is offline
 

eXpert
  
Join Date: May 2006
Location: Canada
Posts: 377
 

Default 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.
__________________
Jack@AquasanaCA
X-CART GOLD 4.0.19 Live
DSEFU, AOM, ezCheckout, ezUpsell, ezRecommends, RememberMe, RememberAnonCarts
AquasanaCanada.com - Aquasana╝ - #1 Rated Water Filters in America!
X-CART GOLD 4.4.5 Live
CDSEO Pro v. 1.8.4
AquasanaMontreal.com
Aquasana╝ & Rhino Water Filtration Systems
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 12:33 AM.

   

 
X-Cart forums © 2001-2020