uknowho008 Posted November 20, 2008 Share Posted November 20, 2008 I'm in the very early stages of making building a shopping cart. The problem is when I add a product to my cart in firefox it add's two of them instead of one but it works fine in IE. I can't figure out what the problem is. Here is the code. function RequestClean($object) { $object = htmlentities(trim(addslashes($_REQUEST["$object"]))); return $object; } function AddTo() { $ModelNum = RequestClean("ModelNum"); $Glass = RequestClean("Glass"); $Metal = RequestClean("Metal"); $Quantity = RequestClean("Quantity"); if($ModelNum AND $Glass AND $Metal AND $Quantity) { $_SESSION["Cart"][] = array("ModelNum"=>"$ModelNum", "Glass"=>"$Glass", "Metal"=>"$Metal", "Quantity"=>$Quantity); } } if(IsSet($_REQUEST["AddTo"])) { AddTo(); } elseif(IsSet($_REQUEST["ClearCart"])) { session_destroy(); $_SESSION["Cart"] = ""; } Quote Link to comment https://forums.phpfreaks.com/topic/133422-_session-gets-added-twice-in-firefox/ Share on other sites More sharing options...
PFMaBiSmAd Posted November 20, 2008 Share Posted November 20, 2008 FF will request a page a second time to apply its' default character encoding when it cannot figure out the character set encoding being used on a page or the page has none specified. Firefox considers this to be a feature, I would call it a bug (FF already has the page, why request it again.) The best solution would be to set a session variable that says that the form processing code has executed once and then check this variable at the start of your code and skip the form processing for all the requests after the first one. Quote Link to comment https://forums.phpfreaks.com/topic/133422-_session-gets-added-twice-in-firefox/#findComment-693958 Share on other sites More sharing options...
uknowho008 Posted November 20, 2008 Author Share Posted November 20, 2008 Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/133422-_session-gets-added-twice-in-firefox/#findComment-693961 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.