Welcome Guest, Not a member yet? Register   Sign In
SSL in CodeIgnitor
#10

[eluser]Rick Jolly[/eluser]
A couple of comments:

1) To avoid your problem with multiple secure ports, instead of using the server port ($_SERVER['SERVER_PORT']), use $_SERVER['HTTPS'].
Code:
// example:
$protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http';


2)Instead of essentially duplicating the base_url(), site_url(), and redirect() just to add an "s" to "http", override them to add an optional "protocol" parameter. I won't comment on anchor() or form_open() since I don't use them.

Edit:
3)By default, if the current protocol is https, then the base_url should be https as well. That way all images, js, and css includes will use https by default and you'll avoid warnings in IE. Exceptions for unsecure site links can be made by specifying http protocol in the overriden url helper methods above. There shouldn't be a need for a "secure_base_url" config value.
Code:
// example:
$config['protocol'] = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http';
$config['base_url'] = $config['protocol'] . '://your-site.com/';

// and your base_url method could look like this:
function base_url($protocol = false)
{
  $CI =& get_instance();
  $base_url = $CI->config->slash_item('base_url');
  if (($protocol) AND ($pos = strpos($base_url, '://')))
  {
     $base_url= $protocol . substr($base_url, $pos);
  }
  return $base_url;
}

CI should seperate the protocol from base_url in the config imo.


Messages In This Thread
SSL in CodeIgnitor - by El Forum - 11-18-2008, 12:48 PM
SSL in CodeIgnitor - by El Forum - 11-18-2008, 12:49 PM
SSL in CodeIgnitor - by El Forum - 11-18-2008, 12:51 PM
SSL in CodeIgnitor - by El Forum - 11-18-2008, 12:53 PM
SSL in CodeIgnitor - by El Forum - 11-19-2008, 06:54 PM
SSL in CodeIgnitor - by El Forum - 11-20-2008, 09:10 AM
SSL in CodeIgnitor - by El Forum - 12-02-2008, 09:14 AM
SSL in CodeIgnitor - by El Forum - 12-11-2008, 02:16 PM
SSL in CodeIgnitor - by El Forum - 01-12-2009, 06:57 PM
SSL in CodeIgnitor - by El Forum - 01-12-2009, 09:57 PM
SSL in CodeIgnitor - by El Forum - 01-13-2009, 10:04 AM
SSL in CodeIgnitor - by El Forum - 01-17-2010, 08:49 PM
SSL in CodeIgnitor - by El Forum - 02-03-2011, 08:31 AM
SSL in CodeIgnitor - by El Forum - 02-04-2011, 06:19 AM
SSL in CodeIgnitor - by El Forum - 03-10-2011, 12:17 AM



Theme © iAndrew 2016 - Forum software by © MyBB