Last active
January 13, 2016 08:07
-
-
Save sfengyuan/8deec78f9a138656adca to your computer and use it in GitHub Desktop.
Codeigniter csrf token helper
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
// In codeigniter, form_open() can automatic output a csrf token field. | |
// But, I prefer use the html form tag. | |
// This function can manually insert a token to form elements. | |
function csrf_token() | |
{ | |
$CI = & get_instance(); | |
$hidden[$CI->security->get_csrf_token_name()]= $CI->security->get_csrf_hash(); | |
$form_token = sprintf("<div style=\"display:none\">%s</div>", form_hidden($hidden)); | |
echo $form_token; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment