dozpox8752 2012-05-14 08:50
浏览 67
已采纳

在PHP中是否有任何方法可以检测请求是否来自浏览器后退按钮?

I'm working on wordpress plugin, which handles shopping cart. I have two pages, checkout and thank you page. Items to cart are added by link like that https://mysite.com/checkout/?action=add&subscription=23 . I'm using Session for adding items to the cart on checkout page.

Suppose if I add three items added: https://mysite.com/checkout/?action=add&subscription=1 https://mysite.com/checkout/?action=add&subscription=2 https://mysite.com/checkout/?action=add&subscription=3 (Last link in browser addressbar)

When user checkout on checkout page then user is redirected to thank you page. I have problem with browser back button, If user press back button on thank you, he is redirected again to checkout page with last item again added (https://mysite/checkout/?action=add&subscription=3 ) since this was the last link in browser address bar.

How can i prevent browser to add last item again on user back button press on thank you page? Is there any way in PHP to detect if request is coming from browser back button? I think, there can be way to handle it using session?

Please guide me if there is any other suitable way to accomplish this? Thanks

  • 写回答

3条回答 默认 最新

  • doujiong2533 2012-05-14 08:55
    关注

    The best way to handle that is to use the POST/REDIRECT/GET pattern.

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

报告相同问题?

悬赏问题

  • ¥100 有人会搭建GPT-J-6B框架吗?有偿
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名