Posts

Showing posts from August, 2013

Adjust phpMyAdmin Session Timeout

There are 2 ways to adjust the session timeout or expiration: PHPMyAdmin Web Interface 1. Go to Settings → Features 2. Adjust value of Login cookie validity PHPMyAdmin configuration file 1. Locate config.inc.php in /path/to/phpmyadmin/ 2. Adjust the value of this line: $cfg['LoginCookieValidity'] = 3600; /* set the expiration time to 1 hour */ or add $cfg['Servers'][$i]['LoginCookieValidity'] = 3600; Please note that session.gc_maxlifetime might limit session validity and if the session is lost, the login cookie is also invalidated. So it is a good idea to set session.gc_maxlifetime in php.ini

CodeIgniter: Add Session in Twig

To add the session variable on your twig template, you have to add the following line in your Twig library or controller. $this->_twig->addGlobal("session", $this->CI->session); Then on your twig template, you can print the session like this {{ session.userdata.username }} Since in CodeIgniter, the session stored by user is usually in the userdata array. Otherwise, you can just simply call the session variable and name {{ session.username }}

Load Bootstrap Modal from AJAX using jQuery

index.html <!-- putting the link in data-href instead of href removes the js error "Uncaught Error: Syntax error, unrecognized expression: /path/to/file --> <a class="btn btn-primary" data-href="modal_content.html" data-toggle="modal" href="#">Show Modal</a> modal_content.html <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h4 class="modal-title">Modal Title</h4> </div> <div class="modal-body"> Modal Body </div> <div class="modal-footer"> <button class="btn btn-default" data-dismiss="modal" type="button"> Close </button> <button class="btn btn-primary" type="button"> Save Ch

Install Anomareh PHP-Twig.tmbundle on Sublime Text 3

So this bundle for Sublime Text is made by Anomareh Basically, what it does is integrate Twig to the said IDE by providing syntax highlighting and auto-completion for Twig when using Sublime. So here's how to install the package. Download the package at https://github.com/Anomareh/PHP-Twig.tmbundle Unzip then copy all the files and folders In Sublime, click Browse Packages under the Preferences menu Create a directory named Twig on Packages folder Paste the files that you copied earlier into the Twig folder Restart Sublime Now, in your twig file, click on the bottom right of the sublime window (a drop up/down should appear) Select HTML (Twig) from the list of languages to enable the package. This should work on Sublime Text 2 as well.

Adding template engine Twig on CodeIgniter

Image
1. Download Twig vendor from http://twig.sensiolabs.org/ 2. Extract the files and copy the contents of the Twig-1.x.x\lib to /application/libraries/ Your library should have the Twig folder inside /libraries/Twig 3. Create a Twig.php inside the libraries folder then add the following code: class Twig { private $CI; private $_twig; private $_template_dir; private $_cache_dir; public function __construct($debug = false) { $this->CI =& get_instance(); self::requireTwigAutoloader(); Twig_Autoloader::register(); $this->CI->config->load('twig'); $this->_template_dir = $this->CI->config->item('template_dir'); $this->_cache_dir = $this->CI->config->item('cache_dir'); $loader = new Twig_Loader_Filesystem($this->_template_dir); $this->_twig = new Twig_Environment($loader, array( 'cache' => $this-&