This is 1 of the way I am currently practicing,
-
Implant csrf, and salt tempt token along with the request to be made by user, and validate them all together from the request. Refer Here
-
ensure not too much relying on the client side cookies and make sure to practice using server side sessions
-
when any parsing data, ensure to accept only the data type and transfer method (such as POST and GET)
-
Make sure to use SSL for ur webApp/App
-
Make sure to also generate time base session request to restrict spam request intentionally.
-
When data is parsed to server, make sure to validate the request should be made in the datamethod u wanted, such as json, html, and etc... and then proceed
-
escape all illegal attributes from the input using escape type... such as realescapestring.
-
after that verify onlyclean format of data type u want from user.
Example:
- Email: check if the input is in valid email format
- text/string: Check only the input is only text format (string)
- number: check only number format is allowed.
- etc. Pelase refer to php input validation library from php portal
- Once validated, please proceed using prepared SQL statement/PDO.
- Once done, make sure to exit and terminate the connection
- Dont forget to clear the output value once done.
Thats all I believe is sufficient enough for basic sec. It should prevent all major attack from hacker.
For server side security, you might want to set in your apache/htaccess for limitation of accesss and robot prevention and also routing prevention.. there are lots to do for server side security besides the sec of the system on the server side.
You can learn and get a copy of the sec from the htaccess apache sec level (common rpactices)