Recommend this page to a friend! |
![]() ![]() |
Info | ![]() |
![]() |
![]() ![]() |
Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2022-06-30 (1 month ago) ![]() | Not yet rated by the users | Total: 53 This week: 1 | All time: 10,260 This week: 227![]() |
Version | License | PHP version | Categories | |||
csrf-class 1.0 | GNU Lesser Genera... | 5 | HTML, PHP 5, Security |
Description | Author | |
This class can generate and validate tokens to avoid CSRF attacks. |
|
its easy to use , its simple already
1 - include CSRF-class to your project :
<?php
include_once("project-dir/libs/Csrf.php");
2 - initialize CSRF-class :
$token = CSRF::init();
3 - check if token its match :
// first method
if($token->checkToken())
{
// process last action
}
else
{
// Oops, something error (SCRF Attack)
}
// you can send token value to this method
if($token->checkToken($_POST['token']))
{
// process last action
}
else
{
// Oops, something error (SCRF Attack)
}
// other method :
$token->validOrDie(); // any error ??? then kill the page
// process last action
we have only one public helper , its :
this method to create token input field.
<form action="?ok" method="POST">
<input type="text">
<br>
<input type="submit" value="SUBMIT">
<?php echo $token->csrfField() ?>
</form>
in other hand you can create this field manually and pass token value
<form action="?ok" method="POST">
<input type="text">
<br>
<input type="submit" value="SUBMIT">
<input type="hidden" name="_token" value="<?php echo $token->getToken() ?>">
</form>
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.