Created
January 3, 2020 16:10
-
-
Save jsanbae/09ddad855c3cc9b53182b428d26c6a05 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
/** | |
* A view Helper from CSRF | |
* | |
* Prints the Token | |
* | |
* @author Javier Sanchez | |
*/ | |
class Zend_View_Helper_Csrf extends Zend_View_Helper_Abstract { | |
public function CsrfViewHelper() | |
{ | |
return $this; | |
} | |
public function getToken() | |
{ | |
$session = new Zend_Session_Namespace('CsrfProtect'); | |
if (!isset($session->key)) { | |
throw new RuntimeException('Token non-existent'); | |
} else { | |
return $session->key; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment