dsuoedtom207012191 2011-08-18 05:20
浏览 20
已采纳

购物车更新的建议

I am working on a shopping on a online store for my brother. I am stuck in the in the process where the buyers cart is updated when he adds items to the basket . I want to know how to remember the buyer (as my bro wants user can buy without sign in,so no case of user id etc)? Should I create a session for him and save it to database?

  • 写回答

2条回答 默认 最新

  • duanjinchen5296 2011-08-18 05:28
    关注

    Yes, you will have to create a session to remember them between clicks, otherwise you will have to tack on some sort of id in the GET parameters.

    Take a look at session_start() and the examples they give you: http://php.net/manual/en/function.session-start.php

    Small warning, native PHP sessions have a vulnerability to session fixation, which could easily to session hijacking (they would need the session id, but after that, they could fix a session). It is always better to create a wrapper and do your best to ensure the user is who they say they are (via the session id) by comparing IPs and User Agents from previous clicks, stored in $_SESSION, to the current IP and User Agent they are presenting.

    I personally recommend setting session.use_only_cookies to 1 to prevent information leaking via the session ID being passed in GET.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法