Jump to content

add into basket


robert_gsfame

Recommended Posts

I wonder how can we create "add into basket", what are they actually using...session or cookies?? then how to create multiple session or cookies??

 

thanks in advance

 

You need to do some reading on PHP Sessions. Yes sessions are used to create a shopping basket application. Cookies are also used but the cookie part is usually behind the scenes and PHP does this automatically for you. A cookie is used to store the session ID on the users computer, which is then transmitted to the server with each page request.

Link to comment
https://forums.phpfreaks.com/topic/196958-add-into-basket/#findComment-1033997
Share on other sites

If i let any users including visitors without registration needed which means that no SESSION ID is required...so i only need to create cookie based on what product they're choosing....is that correct?

 

You'll need a session regardless of whether the user is registered or just a guest. You would not normally store a reference to the product in a cookie. Normally the basket items are stored in the session like here for example, this would add a product to the basket array in the session:

 

$_SESSION['BASKET']['ITEMS'][] = array('product_id' => 1234, 'product_name' => 'Shoes', 'qty' => 1);

Link to comment
https://forums.phpfreaks.com/topic/196958-add-into-basket/#findComment-1034004
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.