Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Maintaining Session Outside of osC


Guest

Recommended Posts

This is probably a pretty silly question, but I've dug around the forums and I haven't stumbled upon a definitive answer as of yet. The "store" portion of my site is supposed to be tightly interwoven with the static site, and I'm concerned about maintaining a user's session should they go into the store, fill up a cart, and then decide to click a link to a static page. I'm sort of assuming that getting the cookies set up properly will help correct this, but the test machine is at work and I'm at home, so I haven't been able to monkey with it. Any suggestions, help, and good-natured insults will be greatly appreciated. Thanks!

 

Aaron

Link to comment
Share on other sites

Requiring cookies would work. If you can make your static pages php pages you could just use the osC wrapper function to generate all of your links. That would solve the problem whether a cookie or sid is used to maintain session.

 

Any reason you can't keep the static pages in the store? Having the side columns would make navigation a lot easier, and would maintain the look and feel of the site. It would serve as a reminder that all those products are there for purchase too. I would go this way unless there are reasons to separate the static pages.

 

Ok, I'll stop babbling now....

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Thanks for the help, Jim - as I said, I had a feeling that cookies would take care of the problem. Unfortunately, they've created a new problem of their own. I'm getting the Cookie Usage page whenever I try to add anything to my cart - even when I lower my IE security level to accept all cookies. A cookie is definitely being set by the store, but it doesn't seem to be helping much. Any thoughts?

Link to comment
Share on other sites

I've seen the same problem, but I'm not certain that it's related. Can you purchase products and complete registration? Do cookies work in other browsers (specifically Opera?)

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

I just installed Opera 7, assuming that it was some weird IE quirk, but was shocked to find that Opera gives the same error. Argh. I tried to set up an account to see if that might get rid of the problem, but the registration process ended in an unrelated error (my SMTP settings aren't correct, since I don't have an SMTP server to work with yet). When I tried to log in, instead of getting the log in page, I got cookie_usage.php again.

 

I can't think of anything that would be a problem. As far as I can tell, everything is set up properly, and the cookie is definitely being written. I'm desperate to get it working, since a store that can't maintain state doesn't do anyone much good.

Link to comment
Share on other sites

Ok, I have a few more things for you to check. Is your server running PHP in safe mode? If not, check both of your configure.php files for absolute paths, and check the cookie path. You can set the cookie path to your catalog directory.

 

Let us know what happens.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Hi again, Jim. Thanks for your continued help on this. PHP isn't running in safe mode. The paths in configure.php are all relative - should I try absolute? Also, I don't know if this could be the cause of the issue or not, but I'm running the server on my local machine, which is a Win2K box. As far as I know, it's a really standard setup, and Apache, MySQL, and PHP seem to be playing well together - this cookie problem is the only persistent issue I've had with osCommerce. I'd love to get it out of the way so I can put the finishing touches on my store.

 

Thanks again for your help!

 

Aaron

Link to comment
Share on other sites

Hi Aaron

 

I'm also running my development system on a Win2k box, so this should work. You definitely need absolute paths for all of the filesystem defines -- the ones with the _FS_ in the name. The only one you should need to change is the DIR_FS_CATALOG, since all the others are referenced to it. You need to do this change in both the catalog/includes and admin/includes directories. Beware of using $DOCUMENT_ROOT -- my windows box puts a slash at the end of the string, but the code is not expecting the slash (*nix boxes don't seem to add it.)

 

If you are just running locally this will do the job. You will probably need a different config file for your production server, since the absolute paths will be different. Don't worry about that until the time comes to move the code.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Hey Jim -

Everything looks fine in my configure.php files, but I'll show them here just to be on the safe side. I'm very seriously considering just spending the weekend cobbling together a Linux box to get this running on since it's probably going to be hosted on *nix server anyway... Here's the config files:

 

First is /catalog/includes/configure.php

<?php
/*
 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

// Define the webserver and path parameters
// * DIR_FS_* = Filesystem directories (local/physical)
// * DIR_WS_* = Webserver directories (virtual/URL)
 define('HTTP_SERVER', 'http://127.0.0.1'); // eg, http://localhost - should not be empty for productive servers
 define('HTTPS_SERVER', ''); // eg, https://localhost - should not be empty for productive servers
 define('ENABLE_SSL', false); // secure webserver for checkout procedure?
 define('HTTP_COOKIE_DOMAIN', '127.0.0.1');
 define('HTTPS_COOKIE_DOMAIN', '127.0.0.1');
 define('HTTP_COOKIE_PATH', '/catalog/');
 define('HTTPS_COOKIE_PATH', '/catalog/');
 define('DIR_WS_HTTP_CATALOG', '/catalog/');
 define('DIR_WS_HTTPS_CATALOG', '');
 define('DIR_WS_IMAGES', 'images/');
 define('DIR_WS_ICONS', DIR_WS_IMAGES . 'icons/');
 define('DIR_WS_INCLUDES', 'includes/');
 define('DIR_WS_BOXES', DIR_WS_INCLUDES . 'boxes/');
 define('DIR_WS_FUNCTIONS', DIR_WS_INCLUDES . 'functions/');
 define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/');
 define('DIR_WS_MODULES', DIR_WS_INCLUDES . 'modules/');
 define('DIR_WS_LANGUAGES', DIR_WS_INCLUDES . 'languages/');

 define('DIR_WS_DOWNLOAD_PUBLIC', 'pub/');
 define('DIR_FS_CATALOG', 'c:/program files/apache group/apache/htdocs/catalog/');
 define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/');
 define('DIR_FS_DOWNLOAD_PUBLIC', DIR_FS_CATALOG . 'pub/');

// define our database connection
 define('DB_SERVER', '127.0.0.1'); // eg, localhost - should not be empty for productive servers
 define('DB_SERVER_USERNAME', '');
 define('DB_SERVER_PASSWORD', '');
 define('DB_DATABASE', 'storedb');
 define('USE_PCONNECT', 'false'); // use persistent connections?
 define('STORE_SESSIONS', ''); // leave empty '' for default handler or set to 'mysql'
 
// CLR 020605 defines needed for Product Option Type feature.
define('PRODUCTS_OPTIONS_TYPE_SELECT', 0);
define('PRODUCTS_OPTIONS_TYPE_TEXT', 1);
define('PRODUCTS_OPTIONS_TYPE_RADIO', 2);
define('PRODUCTS_OPTIONS_TYPE_CHECKBOX', 3);
define('TEXT_PREFIX', 'txt_');
define('PRODUCTS_OPTIONS_VALUE_TEXT_ID', 0); //Must match id for user defined "TEXT" value in db table TABLE_PRODUCTS_OPTIONS_VALUES 
 
?>

 

And then admin/includes/configure.php

<?php
/*
 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

// Define the webserver and path parameters
// * DIR_FS_* = Filesystem directories (local/physical)
// * DIR_WS_* = Webserver directories (virtual/URL)
 define('HTTP_SERVER', 'http://127.0.0.1'); // eg, http://localhost - should not be empty for productive servers
 define('HTTPS_SERVER', ''); // eg, https://localhost - should not be empty for productive servers
 define('ENABLE_SSL', false); // secure webserver for checkout procedure?
 define('HTTP_COOKIE_DOMAIN', '127.0.0.1');
 define('HTTPS_COOKIE_DOMAIN', '127.0.0.1');
 define('HTTP_COOKIE_PATH', '/catalog/');
 define('HTTPS_COOKIE_PATH', '/catalog/');
 define('DIR_WS_HTTP_CATALOG', '/catalog/');
 define('DIR_WS_HTTPS_CATALOG', '');
 define('DIR_WS_IMAGES', 'images/');
 define('DIR_WS_ICONS', DIR_WS_IMAGES . 'icons/');
 define('DIR_WS_INCLUDES', 'includes/');
 define('DIR_WS_BOXES', DIR_WS_INCLUDES . 'boxes/');
 define('DIR_WS_FUNCTIONS', DIR_WS_INCLUDES . 'functions/');
 define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/');
 define('DIR_WS_MODULES', DIR_WS_INCLUDES . 'modules/');
 define('DIR_WS_LANGUAGES', DIR_WS_INCLUDES . 'languages/');

 define('DIR_WS_DOWNLOAD_PUBLIC', 'pub/');
 define('DIR_FS_CATALOG', 'c:/program files/apache group/apache/htdocs/catalog/');
 define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/');
 define('DIR_FS_DOWNLOAD_PUBLIC', DIR_FS_CATALOG . 'pub/');

// define our database connection
 define('DB_SERVER', '127.0.0.1'); // eg, localhost - should not be empty for productive servers
 define('DB_SERVER_USERNAME', '');
 define('DB_SERVER_PASSWORD', '');
 define('DB_DATABASE', 'storedb');
 define('USE_PCONNECT', 'false'); // use persistent connections?
 define('STORE_SESSIONS', ''); // leave empty '' for default handler or set to 'mysql'
 
// CLR 020605 defines needed for Product Option Type feature.
define('PRODUCTS_OPTIONS_TYPE_SELECT', 0);
define('PRODUCTS_OPTIONS_TYPE_TEXT', 1);
define('PRODUCTS_OPTIONS_TYPE_RADIO', 2);
define('PRODUCTS_OPTIONS_TYPE_CHECKBOX', 3);
define('TEXT_PREFIX', 'txt_');
define('PRODUCTS_OPTIONS_VALUE_TEXT_ID', 0); //Must match id for user defined "TEXT" value in db table TABLE_PRODUCTS_OPTIONS_VALUES 
 
?>

 

Thanks for the help. Unless something is glaringly obvious, I think I'll end up going the Linux route. Of course, if that doesn't solve the problem, I'm really in trouble...

 

Aaron

Link to comment
Share on other sites

i run an osc/pn site on linux and when my members switch between either it makes no difference, all settings/cart items are remembered.

PropertyIreland.net is the site, once you go there you are on osc, add anything to your interest bucket and if you click on the forum button at the top of the page you go to postnuke, if you go back your cart is remembered.

 

I am playing with another site at the moment wwpcs at the moment and the same happens - I never realised it was an issue - maybe a windows thing?

Link to comment
Share on other sites

Aaron: Your configuration looks good. You could try setting

define('STORE_SESSIONS', 'mysql')

I remember having to do this to get cookies to work. My system is now set to not force cookies and it's still sending the cookie. I have Firebird set to ask permission before it allows a cookie (So I can tell when the server is trying to set one.) Internet Explorer and Opera are working as well.

 

Other than that, the only difference is that my WS root is set to the actual site name, with an alias set in the HOSTS file to trick it into staying on the local server. I may have made some other changes when I was getting things working, but I don't remeber anything else right now.

 

I do have osC set up on a remote hosted site running linux, but that isn't working right now. The bugs can be quite different, which makes debugging really fun. My Windows box was a lot more forgiving about having relative paths set.

 

daithi: If you require cookies the cart will be retained for the life of the cookie (30 days on default osC.) You should not stay logged in if using a sid for tracking, since the external site won't pass the sid. I'm not certain how that works with postnuke. Do you see a sid on the postnuke side?

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Okay, I set the session storage to MySQL and continued to run into good ol' cookie_usage.php, so I set Force Cookie Use to false. Lo and behold, no more cookie_usage.php. I even threw something into the basket and then left the site, returning to the store's front page to see that the basket infobox was still there (it isn't shown if the basket is empty) and was still displaying the product I had added. I was about to declare victory when some nagging little voice inside my head told me I oughtta click around the site a bit, just to be on the safe side. As soon as I left the front page to go anywhere, the cart was emptied. If I stayed on the front page and reloaded it, the cart stayed. Very odd. I'm going to turn off session regeneration and see if that has an effect, but the Linux option is starting to look good just because it's different.

Link to comment
Share on other sites

I just don't know. Mine still works -- I just tried a couple of test orders, changed my address, etc. Everything works. Possibly some setting that I just happened to get right?

 

Sorry I can't help any more. Please let us know if you figure it out.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Thanks again for all of your help - I may uninstall and reinstall osC, or I may follow through on the Linux idea. I probably introduced a quirk somewhere in all of my tinkering, so I'll spend a little time backtracking and see what I find. I really appreciate your time and effort in helping out.

 

Aaron

Link to comment
Share on other sites

  • 2 years later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...