Skip to content

sahithvibudhi/PHP-CSRF-Protection-class

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

PHP CSRF Protection class

easy to use csrf helper class for PHP

How to use?

where ever you have a form, use CSRF::putTokenField(); to insert a hidden token input field, which is used to check if the request is valid or a CSRF.

example:

//include the CSRF.php file which is in Helpers folder
<form action='submit.php' method='POST'>
<input type='text' name='comment'>
<?php CSRF::putTokenField(); ?>
<input type='submit' name='submit'>
</form>

To check if incomming request is a valid request and has a token use CSRF::isValidRequest()

if(isset($_POST['submit'])){
  if(CSRF::isValidRequest()){
    //your logic
  }
}

[or]

CSRF::isValidRequest();
//logic

CSRF::isValidRequest() will kill the execution if there is no valid token

About

a easy to use csrf helper class for PHP

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages