loxy1914 Posted November 22, 2011 Share Posted November 22, 2011 Hello. I want to implement a simple shopping cart with sessions but without using DB, despite the fact that I have a DB consisting of Car-Shop-Customer. Is the only way using arrays? Quote Link to comment https://forums.phpfreaks.com/topic/251615-sessions-in-cart/ Share on other sites More sharing options...
ZulfadlyAshBurn Posted November 22, 2011 Share Posted November 22, 2011 you can use cookie too. Quote Link to comment https://forums.phpfreaks.com/topic/251615-sessions-in-cart/#findComment-1290408 Share on other sites More sharing options...
loxy1914 Posted November 22, 2011 Author Share Posted November 22, 2011 OK, but in the case I would like to add a new car into the shopping cart, where should I keep the cart`s data. For example, I order a new car, color green, price 10000, firm VW. These are too much for a unique session. Am I wrong? Quote Link to comment https://forums.phpfreaks.com/topic/251615-sessions-in-cart/#findComment-1290413 Share on other sites More sharing options...
ZulfadlyAshBurn Posted November 22, 2011 Share Posted November 22, 2011 create an array then store it into the session. example <?php session_start(); $carnew = array(); $model = $_GET['model']; $color = $_GET['color']; $price = $_GET['price']; $firm = $_GET['firm']; $carnew['0'] = $model; $carnew['1'] = $color; $carnew['2'] = $price; $carnew['3'] = $firm; $_SESSION['cars'] = array(); $_SESSION['cars']['0'] = $carnew; print_r($_SESSION['cars']); ?> Quote Link to comment https://forums.phpfreaks.com/topic/251615-sessions-in-cart/#findComment-1290416 Share on other sites More sharing options...
loxy1914 Posted November 22, 2011 Author Share Posted November 22, 2011 Nice. I think it is very much better now... Thank you very much. Solved. Quote Link to comment https://forums.phpfreaks.com/topic/251615-sessions-in-cart/#findComment-1290433 Share on other sites More sharing options...
ZulfadlyAshBurn Posted November 22, 2011 Share Posted November 22, 2011 HAHA. OK Quote Link to comment https://forums.phpfreaks.com/topic/251615-sessions-in-cart/#findComment-1290435 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.