What are the best practices for avoiding xss attacks in a PHP site

前端 未结 20 2585
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-22 02:34

I have PHP configured so that magic quotes are on and register globals are off.

I do my best to always call htmlentities() for anything I am outputing that is derive

20条回答
  •  滥情空心
    2020-11-22 03:16

    • Don't trust user input
    • Escape all free-text output
    • Don't use magic_quotes; see if there's a DBMS-specfic variant, or use PDO
    • Consider using HTTP-only cookies where possible to avoid any malicious script being able to hijack a session

提交回复
热议问题