CodeIgniter security-Related settings Rollup _php instance

Source: Internet
Author: User
Tags sql injection codeigniter

The CodeIgniter framework itself provides security settings such as prevention against XSS and csrf attacks, prevention against SQL injection attacks, and so on.

In the case of a configuration file:

In the application/config/config.php

$config [' encryption_key '] = ';//This must be set to encrypt their own cookies
$config [' cookie_secure '] = true;//set to TRUE/
*
| ------------------------------------------------------------------------
| Global XSS filtering globally XSS filter set to True
|------------------------------------------------------------------------ --
|
| Determines whether the XSS filter is always active as get, POST or
| COOKIE data is encountered
|
* *
$config [' global_xss_filtering '] = TRUE;
Guard against CSRF attacks
$config [' csrf_protection '] = TRUE;
$config [' csrf_token_name '] = ' mall_tooken ';
$config [' csrf_cookie_name '] = ' mall_cookie ';
$config [' csrf_expire '] = 7200;//Set the appropriate time

Open system/core/input.php

Set the $xss_clean in Get and post methods to true of course, if your site is safe and indifferent, it is not set or explicitly set when calling get or post parameters.

The development of the need to note:

1. Use

$this->input->get (' name ', true);

Instead of using $_get[' name ';

2. Use

$this->input->post (' name ', true);

Instead of using $_post[' name ';

3. Use ActiveRecord query statements and try to avoid statements such as Select

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.