Skip to content

Instantly share code, notes, and snippets.

@jlamim
Created April 27, 2016 13:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlamim/4afa04ad2e83a1ac6a23ba963b59c7ab to your computer and use it in GitHub Desktop.
Save jlamim/4afa04ad2e83a1ac6a23ba963b59c7ab to your computer and use it in GitHub Desktop.
Reforçando a segurança com CSRF - Gerando o token no controller
<?php
// Gera o name e o hash para o campo hidden
$data['csrf'] = array(
'name' => $this->security->get_csrf_token_name(),
'hash' => $this->security->get_csrf_hash()
);
// Passa os valores para a view
$this->load->view('view', $data);
?>
// View recuperando os tokens
<input type="hidden" name="<?=$csrf['name'];?>" value="<?=$csrf['hash'];?>" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment