<form method="post" action="http://www.example.com/login">
<input type="text" name="text_Box" />
<input type="password" name="pass_word" />
<input type="submit" name="submit">
</form>
当我提交表格并在控制器中
public function login(){
$pass_word = $this->input->post('pass_word');
die($pass_word);
}
这里的问题,它显示了普通密码,如果我在控制器中键入123456,我得到123456.
>这是安全问题吗?
>任何人都可以通过wireshark等网络监控工具获取密码吗?
怎么避免这个?在发送到控制器之前,我可以在视图中加密密码吗?请提前帮助,谢谢.
首先,我刚刚阅读了有关SSL和HTTPS的一般信息,以及SSL证书 – Wiki,Google和SO都是很好看的地方,那里有很多信息.
对于使用带有CI的SSL / HTTPS,我发现这些有用:
> http://sajjadhossain.com/2008/10/27/ssl-https-urls-and-codeigniter/
> http://nigel.mcbryde.com.au/2009/03/working-with-ssl-in-codeigniter/
> How can I have CodeIgniter load specific pages using SSL?
特别是强制ssl功能从Nigel’s post:
Create a file in application/helper called ssl_helper.PHP
if (!function_exists('force_ssl'))
{
function force_ssl()
{
$CI =& get_instance();
$CI->config->config['base_url'] =
str_replace('http://','https://',$CI->config->config['base_url']);
if ($_SERVER['SERVER_PORT'] != 443)
{
redirect($CI->uri->uri_string());
}
}
}
function remove_ssl()
{
$CI =& get_instance();
$CI->config->config['base_url'] =
str_replace('https://','http://',$CI->config->config['base_url']);
if ($_SERVER['SERVER_PORT'] != 80)
{
redirect($CI->uri->uri_string());
}
}
Load the helper,then in the constructor for any controller that
requires ssl,simply insert:
force_ssl();In every controller that you don’t want to have ssl put:
if (function_exists('force_ssl')) remove_ssl();
这是一种编程方法,另一种方法是使用.htaccess(如果你使用的是Apache).