• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CodeIgniter Simple and Secure Twig

#18
(10-22-2015, 04:19 PM)mukitti Wrote: How can I use  CI session in Twig template?

Session variables are variables. So it can be used in the same way as other variables.

In controller:

PHP Code:
       $this->load->library('session');
 
       $_SESSION['test'] = 'test';
 
       $data['session'] = $_SESSION;
 
       $this->twig->display('welcome/index'$data); 

In twig file:

PHP Code:
{{ session.test }} 
Do you want to write tests for your apps? Our book, CodeIgniter Testing Guide would help you.
Reply


Messages In This Thread
CodeIgniter Simple and Secure Twig - by kenjis - 05-24-2015, 07:06 PM
RE: CodeIgniter Simple and Secure Twig - by kenjis - 10-22-2015, 10:46 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.