ds3464 2011-01-10 22:55
浏览 24
已采纳

使用表单与链接进行注销功能有什么好处?

I'm building a web app and just working on the logout functionality (simple session unset / meta refresh/redirect code on logout.php)

Possible a simple question (though I've hunted around on Google to no avail), but for the logout button on the site, is there any benefit in using a form that submits to logout.php vs a button graphic with an a href that links to the same page?

Functionally, they both seem to work the same, but is there any potential security issue etc?

Thanks heaps!

  • 写回答

2条回答 默认 最新

  • dtrhd2850 2011-01-10 23:08
    关注

    There are two things that miiiight be relevant here:

    1. If it's a form and it POSTs instead of GETting, you will need to redirect to get around the usual browser back button + POST data unpleasantness. Of course you already mention redirecting, so this is probably not relevant.
    2. Since HTTP GET requests are supposed to be idempotent, "the right way" to do it should be with POST, which means a form. However, this kind of argument lacks practical justification. You should be just fine with links unless some ill-behaved and/or misconfigured browser addon decides to make life difficult for your users.

    In essence, there should be no practical difference.

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

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路