Category: CodeIgniter

  • Security

    XSS Prevention XSS means cross-site scripting. CodeIgniter comes with XSS filtering security. This filter will prevent any malicious JavaScript code or any other code that attempts to hijack cookie and do malicious activities. To filter data through the XSS filter, use the xss_clean() method as shown below. You should use this function only when you are submitting…

  • Internationalization

    The language class in CodeIgniter provides an easy way to support multiple languages for internationalization. To some extent, we can use different language files to display text in many different languages. We can put different language files in application/language directory. System language files can be found at system/language directory, but to add your own language…

  • Adding JS & CSS

    Adding JavaScript and CSS (Cascading Style Sheet) file in CodeIgniter is very simple. You have to create JS and CSS folder in root directory and copy all the .js files in JS folder and .css files in CSS folder as shown in the figure. For example, let us assume, you have created one JavaScript file sample.js and…

  • Benchmarking

    Setting Benchmark Points If you want to measure the time taken to execute a set of lines or memory usage, you can calculate it by using Benchmarking points in CodeIgniter. There is a separate “Benchmarking” class for this purpose in CodeIgniter. This class is loaded automatically; you do not have to load it. It can…

  • Application Profiling

    When building a web application, we are very much concerned about the performance of the website in terms of how much time the controller took to execute and how much memory is used. Not only the performance, but we also need to see the insights of data like POST data, data of database queries, session…

  • Page Redirection

    While building web application, we often need to redirect the user from one page to another page. CodeIgniter makes this job easy for us. The redirect() function is used for this purpose. Syntax redirect($uri = ”, $method = ‘auto’, $code = NULL) Parameters $uri (string) − URI string$method (string) − Redirect method (‘auto’, ‘location’ or ‘refresh’)$code (string) − HTTP Response…

  • Page Caching

    Caching a page will improve the page load speed. If the page is cached, then it will be stored in its fully rendered state. Next time, when the server gets a request for the cached page, it will be directly sent to the requested browser. Cached files are stored in application/cache folder. Caching can be enabled on…

  • Common Functions

    CodeIgniter library functions and helper functions need to be initialized before they are used but there are some common functions, which do not need to be initialized. These common functions and their descriptions are given below. Syntax is_php($version) Parameters $version (string) − Version number Return TRUE if the running PHP version is at least the one…

  • Cookie Management

    Cookie is a small piece of data sent from web server to store on client’s computer. CodeIgniter has one helper called “Cookie Helper” for cookie management. Syntax set_cookie($name[, $value = ”[, $expire = ”[, $domain = ”[, $path = ‘/’[, $prefix = ”[, $secure = FALSE[, $httponly = FALSE]]]]]]]]) Parameters $name (mixed) − Cookie name or associative array of all of the…

  • Tempdata

    In some situations, where you want to remove data stored in session after some specific time-period, this can be done using tempdata functionality in CodeIgniter. Add Tempdata To add data as tempdata, we have to use mark_as_tempdata() function. This function takes two argument items or items to be stored as tempdata and the expiration time for those items are as shown below.…