duanping2809 2018-11-27 19:37
浏览 41
已采纳

PHP购物车用饼干

I need to do for homework with PHP a list of two products and when i click on anyone of them , the selected product goes to a shopping cart but using COOKIES.

I don't know how to use cookies properly maybe you can help me.

I just need to click in the button/input of one product and then goes listed in a cookie or something like that.

Then if for example i click two times in product A and one time in product B, the cookies takes that info and shows me:

A product x2

B product x1

Ty!!

  • 写回答

1条回答 默认 最新

  • dongyishen5796 2018-11-27 20:24
    关注
            <?php
            //set cookie
            $cookie = "product detail";
            $expire=time()+60*60*24*30;
            setcookie("product_id", $cookie, $expire);
    
           //retrieve detail
           if($product_id == "product id"){
            $name = $_COOKIE["product_id"]
             }
            ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度