PHP Cookie + Shopping cart How to write??

Source: Internet
Author: User
Now do the website to do shopping cart here I will not write!! Please master write code to reference under!! Thanks, man.


Reply to discussion (solution)

The user can not put cookies, the next time users to find the collection in the shopping cart in the product once it is gone

The ajax+ database stores content.

I also need the shopping cart information, 2 floor said ajax+ database is how to realize, have the source word share under ... Thanks, man.

 
  ";   Print_r ($cars _id);//echo "
";//exit;foreach ($cars _id as $pr _id) {if ($pr _id== $product _id) {echo" "; Exit }}if (Empty ($_cookie[buypro])) {Setcookie ("Buypro", $product _id,time () +3600); Setcookie ("Buycount", "1", Time () +3600 );} else{$newpro =$_cookie[buypro]. ",". $product _id; $newcount =$_cookie[buycount]. ",". " 1 "; Setcookie (" Buypro ", $newpro, Time () +3600), Setcookie (" Buycount ", $newcount, Time () +3600);}} Delete if ($act = = "Del") {$buy =$_cookie[buypro]; $cars _id=explode (",", $buy); $buycountary =explode (",", $_cookie[ Buycount]); $newid =array (); $carcount =array (); for ($i =0; $i

In learning

For you to share a full set of points, not enough

index.php
  
  
 
"Width=" 123 "height=" 121 "border=" 0 "/> Name of Goods:
Price of Goods:
&pname= "> Buy
conn.php car.php
Product ID Number of goods Commodity price Total Merchandise Delete
The > Delete
Price S
Submit Order//Return to home//buy.php $pid, "price" = = $price, "num" =>1); }}else{$arr [$pid]=array ("pid" = + $pid, "price" = = $price, "num" =>1);} $_session["Mycar"]= $arr; After the purchase, the array is re-placed in the session, you can see this sessionob_clean () on each page,//Empty the cache header ("location:car.php");//jump to the Shopping Cart interface (car.php)?>


It may not be very powerful, but being a basic function is OK. In accordance with their own requirements can be modified

thinkphp Shopping Cart How to write code

In learning

Not logged in user shopping cart product store to cookie, logged in user to database

 
   
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.