dscbxou1900343 2013-07-25 03:30
浏览 50
已采纳

ajax security与php包含在根目录安全性中

In my opinion, ajax is great in performing request without clicking a link or sending a form. However, I'm worried about its security issue ,or maybe just thinking too much. In ajax, the javascript is viewable to everyone and the php is accessible through web. Would it be possible for the user to direct calling the php script, bypassing htaccess restriction and etc.

There is three option(any suggestion for new option will be appretiated) for me to achieve my goal.

Option A: Page -> clicking button and call ajax -> Display on Page

Option B: Page -> include php file in root directory -> Clicking button to show hidden div(below 10 mysql row) -> Display on page

Option C: Page A -> Clicking button redirect to page B -> include php file in root directory -> show result with multiple page(10+ per page)

Option A will be nice to me however it seems not so secure. Will the answer be same when dueling with overwriting value in mysql table(more security issue have to be concern)?

----------update------------

I'm now using Option C, and using ajax to to accept request, reject request thing base on the result shown on Page B. Still, wondering the security issue of Ajax, to see when will the pro of client+server side scripting of Ajax beat cons of security issue of ajax. Web structure need to be adjusted and improved according to the security issue.

  • 写回答

2条回答 默认 最新

  • dongmengan8620 2013-07-25 03:59
    关注

    There is nothing to stop someone from looking at your JavaScript code, getting the URL to the AJAX call.

    However, if security is a huge issue then look into session variables and the method of storing the value(s). There is file, database and cookie. You do not want php to store session variables in a cookie as these would be accessible to the visitor (they are stored like normal cookies).

    Set a session value, when the AJAX request is made then check if the session value is also set. If it is then continue as per normal. If it isn't (and the session could have timed out) then do nothing.

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

报告相同问题?

悬赏问题

  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容