Secure Your Cakephp Website By Following These Simple Steps!


/ Published in: PHP
Save to your folder(s)

<p>Follow these steps to secure your Cakephp Website:</p>

<p>*Before you actually start using Security Component functionality, make sure you use $components = array (‘Security’, ‘Auth’) in the array so you can extend its functionality in the other components as well.</p>

<p>*Set security level "Medium" or "High" (in core.php config file)</p>

<p>*Add single line of code to your controller’s before Filter () method: $this->Security->requireAuth(‘action_name’) </p>

<p><strong>To assure more security, add few more lines of code in controller section:</strong></p>

<p><code>$key = Security::generateAuthKey ();
$this->set (‘safe’, $key);
$this->Session->write (‘safe’, $key);</code></p>

<p><strong>Or alternatively adding this code sequence in your view</strong></p>

<p><code>echo $this->Form->create(‘Post’);
echo $this->Form->hidden(‘safe’, $safe);
echo $this->Form->input(‘title’);
echo $this->Form->input(‘content’);
echo $this->Form->end(‘Submit’);</code></p>


Copy this code and paste it in your HTML
  1. http://www.cakephpexpert.com/blog/cakephp-security-tips-and-tricks

URL: http://www.cakephpexpert.com/blog/cakephp-security-tips-and-tricks

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.