CodeIgniter – AJAX + Session bug fix

If you’ve used AJAX-heavy web apps built on a CI backend, you might have noticed premature session expiration, even if you’re expiration was set to never expire ($config[‘sess_expiration’] = 0; in application/config/config.php) This was apparently due to AJAX requests not regenerating sessions, and apparent collisions. Long story short, last month there was a patch introduced […]

CodeIgniter – hyphenated URLs

In rewriting an existing site, with many links out in the wild (via advertisements, press releases, etc.), I had to find a way to use hyphenated urls (in the position of controller, method or argument). Checking SO and the CI boards showed various takes. I’ll go through each, and end with my approach. 1. Using […]

CodeIgniter 2 – Extending the Native Controller (CI_Controller)

Missing from the documentation ( for CI 2.x is the requirement that MY_ classes (that extend natives) need to be loaded for use (and if extending a controller, no Loader member is available before the class definition, so would require PHP native include or requires). From the CI forums, here’s a handy autoloader:

With […]

CodeIgniter – application assets location (css, js, images, etc)

It’s not immediately obvious where to put various “assets” when using CI – I’ve seen some folks place them in the /views/ directory, or use routing, or the assets helper (which seems ungainly for any application big enough to justify the use of a framework in the first place). Remember that all your files are […]

CodeIgniter on Windows – remove index.php with .htaccess rewrite

The CI user guide suggests this as a .htaccess to redirect all incoming traffic to index.php (except for direct requests, images, and robots): [text] RewriteEngine on RewriteCond $1 !^(index\.php|images|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L] [/text] …which barfs on windows installs (I happen to be Windows, Apache, MySQL and PHP, but not using a WAMP package). Removing […]