i want to create a login system in PHP PDO that covers sql injection , xss , session hijacking and other attacks .
Asked
Active
Viewed 280 times
-5
-
So, create it. What is stopping you? – Funk Forty Niner Dec 24 '15 at 16:33
2 Answers
1
For Sql Injection you should use PDO prepared statement. There is lots of example available on net
For XSS attack you should store all data with htmlenities or htmlspecialchars with form
htmlspecialchars($string, ENT_QUOTES, 'UTF-8');Prevent session Hijacking you have to manage below changes.
- Use https
Regenerate sessionid after login
regenerate_session_id()store session_id in cookie not with url string
- set the cookie with the HttpOnly and Secure attributes to forbid access via JavaScript
setcookie( 'UserName', 'Bob', 0, '/forums', 'www.example.com', isset($_SERVER["HTTPS"]), true);
you can find more information with below link.
Community
- 1
- 1
nitin jain
- 298
- 6
- 19
0
Well, this one makes that, except it uses mysqli driver. But don't worry , it uses prepared statements, so you are secured against SQL injection, and other related attacks. It is not 100% secure, but it is solid way to create login system. I've used it before. You can edit on your own way.
fugitive
- 357
- 2
- 8
- 26