/ Published in: PHP
A little function I add to the base Page_Controller class that allows you to define what actions are explicitly SSL. It will put users in SSL when they access it and take them out of it when they navigate somewhere else. It is available in any controllers that extend Page_Controller.
Be sure to add `$this->_checkSSL();` to the Page_Controller's `init()` function.
Be sure to add `$this->_checkSSL();` to the Page_Controller's `init()` function.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
protected function _checkSSL() { $needSSL = $inSSL = $destURL = false; // Get static $ssl_actions and see if we need to switch in or out of SSL if($all_ssl_actions = Object::combined_static($this, 'ssl_actions') and is_array($all_ssl_actions) ) { $action = $this->getRequest()->latestParam('Action'); // $this->getAction() always empty?? $needSSL = true; } } if( $needSSL and !$inSSL ){ } elseif( !$needSSL and $inSSL ) { } if( $destURL ) { die('<h1>Your browser is not accepting header redirects</h1><p>Please <a href="'.$destURL.'">click here</a>'); } }