-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
26 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,26 @@ | ||
# csrf-token | ||
Generate random token for CSRF | ||
# CSRF-token | ||
This CSRF-TOKEN is written in PHP and very simple to use. It generate random token in every refresh of the browser page. | ||
|
||
## Generate token | ||
``` | ||
<?php | ||
<form action="index.php" method="post"> | ||
<input type="hidden" name="token" value="Token::generate()>"/> | ||
<input type="text" name="action" placeholder="Enter an action."/> | ||
<input type="submit" value="Submit" name="sub"/> | ||
</form> | ||
?> | ||
``` | ||
+ Place this static function on a hidden input field value. | ||
|
||
## Check Token | ||
``` | ||
<?php | ||
if(Token::check() == True ){ | ||
// Token Validated | ||
} else { | ||
// Do something to restrict | ||
} | ||
?> | ||
``` | ||
+ You can check if the token is valid using Token::generate(); |