RyuMaster Posted January 26, 2013 Posted January 26, 2013 Hi! I have some custom code snippet. Based on GET data, it fills cart with products, and redirects to shopping cart. Also it sets custom session variable on the way. The problem is... it works only once!! If I close browser, use same link again, I get "shopping cart is empty", like no session ID data is passed anymore. WHY??? http://www.balblabla.com/checkout_sample.php?tempData=9884959&name0=Base0 require('includes/application_top.php'); $first = 0; $ses = ""; $q = explode("&",$_SERVER["QUERY_STRING"]); foreach ($q as $qi) { if ($qi != "") { $qa = explode("=",$qi); list ($key, $val) = $qa; if ($val){ if($first != 0) { $products_query = tep_db_query("SELECT * FROM " . TABLE_PRODUCTS_DESCRIPTION . " WHERE products_name = \"".$val ."\""); $products = tep_db_fetch_array($products_query); $products_query2 = tep_db_query("SELECT * FROM " . TABLE_PRODUCTS_ATTRIBUTES . " WHERE options_id = \"6\" AND products_id = \"".$products["products_id"] ."\""); $attributes_mysql = tep_db_fetch_array($products_query2); $attributes = array(6 => $attributes_mysql["options_values_id"]); $cart->add_cart($products["products_id"],1,$attributes); echo "add"; } else { echo "id?". tep_session_id(); $cart->remove_all(); tep_session_register('id_string'); $_SESSION['id_string']= $val; $first = 1; } } } } tep_redirect(tep_href_link(FILENAME_SHOPPING_CART, '', 'NONSSL', true)) And I can see that tep_session_id() always returns correct session variable. Argh!!! Also, backend settings are: Force Cookie Use False Check SSL Session ID False Check User Agent False Check IP Address False Prevent Spider Sessions True Recreate Session True
RyuMaster Posted January 26, 2013 Author Posted January 26, 2013 Also if it helps to understand the problem: On the first, correct time, link looks like this: http://xxxx/shopping_cart.php?osCsid=6667pga27390svq2fmgmhlg985'>http://xxxx/shopping_cart.php?osCsid=6667pga27390svq2fmgmhlg985 and then: http://xxxx/shopping_cart.php So I see that osCsid gets lost, but dunno why
♥14steve14 Posted January 26, 2013 Posted January 26, 2013 In a standard install of oscommerce the oscid is removed from the url after a few clicks, but the session should still keep things like cart contents in the cart. REMEMBER BACKUP, BACKUP AND BACKUP
RyuMaster Posted January 26, 2013 Author Posted January 26, 2013 I have standart install, no custom modifications or anything. Except this php script is my own. So you say this behavior is predictable. hmmm. I thought cart contents are getting removed because oscid is removed, but then maybe I have to look somewhere else for the solution, around the cart empty function I use or something. Still, I checked the order with echo, it always the same. Firstly, function removes cart contents. Then adds products. HMM I did more tests, actually removing those lines completely $cart->remove_all(); tep_session_register('id_string'); $_SESSION['id_string']= $val; still yields same result. So I don't know where to start now.
RyuMaster Posted January 26, 2013 Author Posted January 26, 2013 Actually I did more tests. It always starts working if I close browser/open it again. Else not matter what I do - completely delete cookies, history erase - no good, works just for a first time. Deleting sessions from database not helping too. So if taht is not sessions and cookies, then what? 0_0 headers?
Guest Posted January 26, 2013 Posted January 26, 2013 @@RyuMaster Disable your custom code, check the cart again, if the cart contents stay in the cart, you know your code is incorrect. Chris
Recommended Posts
Archived
This topic is now archived and is closed to further replies.