Possible problem with shopping cart!

greenspun.com : LUSENET : S-Mart Shopping Cart : One Thread

as I was browsing through the S-Mart shopping cart script I was impressed, then I noticed a possible problem with the shopping cart file that is created by S-Mart.

The reffile created is using $ENV('REMOTE_HOST') as the file name This could cause problems due to the fact that sometimes (though rarely) times people have the SAME HOST ADDRESS. If two people with the same address were to shop at your store they would have all the items in their cart that the other person had. And if they were to shop at the same time.... that would be interesting. This would be rare yes, but none-the-less possible.

Here is the fix - go through the script and everywhere it reads REMOTE_HOST change it to REMOTE_ADDR. Make sure you get them all or it will not work right.

Hope this helps someone. Don (onepurpose.com) don@onepurpose.com

-- Don (don@onepurpose.com), May 15, 1999


This is true but it can be resolve with the following solution.

Find the following section in the SMART.CGI file:

sub get_host { $host = $ENV{'REMOTE_HOST'}; $reffile = "$tmpdir$delim$storename-$host"; }

Replace with the following lines:

sub get_host { $host = $ENV{'REMOTE_HOST'}; $p_id = ($$ % 10000); $reffile = "$tmpdir$delim$storename-$host-$p_id"; }

You can also try reading the following column: http://www.greenspun.com/bboard/q-and-a-fetch-msg.tcl?msg_id=000sFi

-- God bless!

-- Patrick Chan (patrickccf@hotmail.com), February 15, 2000.

Moderation questions? read the FAQ