Epimetheus Posted July 3, 2010 Share Posted July 3, 2010 Hello! I'm so confused on my sessions and javascript right now!! I thought I was a decent (not horrid) php programmer, but this problem is making me feel like a total loser and I'm beginning to lose my sanity, lol. I'm working on a shopping cart "hack" (using Wordpress and Shopp), that allows my product to be completed in three different steps. Because of this, I need two different products selected in a particular order to make up one "meta" product, with the unfortunate hijacking of the cart page. How I have it set up now: Step 1: Customer selects a coffee cup, customizes it (adds name or message, etc), and adds it to the cart. I have to use Ajax to hijack the process and add some session data because Shopp sucks and won't allow multiple products at once. $_SESSION['current_step'] is incremented to 2 (as well as some other session data saved along the way, to associate the next product with the coffee cup). Step 2" Product is added to the cart, if Session is step 2, then the "cart" displays a page that asks you to select the type of coffee beans you want in the cup (or t-shirt). When one selects the item from the list and hits the submit button, it increments the session data again, and uses JS to redirect the page to the coffee bean or T-shirt product page. This button increments the session data to step 3 as well. Step 3: User confirms the choice (or can go back to step 2) of the coffee beans or the t-shirt. Once selected, the current step session data is decremented to step 1 and the cart displays the two products as one. (custom code to accomplish this since, once again, Shopp doesn't allow me to do it natively). This solution WORKS... 4 out of 5 times. Sometimes even 9 out of 10 times. Randomly it doesn't seem to set the session data. I'll get to step 3 (and will echo out current session data) and the $_SESSION['current_step'] is still at step 2. WTH? All of my javascript looks like this: $('.mybuttonclass').click(function(){ $.post('path/to/my/class/myclass.php',{var1:"val"}.function(response){if(response!="confirm"){return false;}}); }); ..or whatever to make sure I get a response back. It works when I test it with fake data, and again, it works greater than 75% of the time, and I cannot seem to figure out why it doesn't work those other times. Firebug isn't helping me. For some reason I don't get a response back some of the time. I've spent all week trying to troubleshoot this (been working a little on other stuff), but I'm at the end of my rope when it comes to skill level. What am I missing? Please help!? I'll grovel and kiss feet! Link to comment https://forums.phpfreaks.com/topic/206587-sessions-unstable-issue-with-sessions-and-jquery-work-around/ Share on other sites More sharing options...
Epimetheus Posted July 3, 2010 Author Share Posted July 3, 2010 Anybody? Link to comment https://forums.phpfreaks.com/topic/206587-sessions-unstable-issue-with-sessions-and-jquery-work-around/#findComment-1080835 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.