Category Archives: CodeIgniter

CodeIgniter with Zebra Session

Install

https://github.com/stefangabos/Zebra_Session

index.php

Do not use session_start();

Note: Put $session in $GLOBALS is very important or this variable wont’ be accessible in controllers and data in session will be lost after redirection and won’t be saved in database.

Note:

  1. If session doesn’t work after redirection, try clear all data in table “session_data”

Join in CodeIgniter

 

AjaxResponse Trait for CodeIgniter 2

Usage:

Trait

 

Static function in CodeIgniter

In Model (Products_m.php):

In Controller:

 

Generate Facebook Product Catalog Feed (XML)

Facebook Doc: https://developers.facebook.com/docs/marketing-api/dynamic-product-ads/product-catalog#feed-format

CodeIgniter XML Helper:

Sample Code:

 

utf8mb4

Old utf8 char_set could cause unexpected error like

Here is example string:

To solve this, change char set settings in config file of CodeIgniter:

 

Upload Error Handler

There are 2 configs in php.ini related to upload process:

  • post_max_size
  • upload_max_filesize

If the size of your post is over post_max_size, system could cause an error without any warning and $_POST could be empty for no reason. So it’s important to check post size before you start to process a form submit.

Helper functions:

Other programming issue:

 

base_url config (https or http)

/index.php

/application/config/config.php

 

Codeigniter Cart not working in IE

Chang session setting in config.php:

to

Reference: