Access CI session from smarty templates

How do I access the CI session from smarty templates.

For example before I moved to CI I accessed the php session as

how is this accomplished in CI, uses another method for sessions.


I have a left menu where it shows additional menus if the admin is logged in. The way it was used to display is that I created a
when the admin log in was successful.

How can I accomplish this, I created a
in CI, but not sure how to check it in smarty or how to access the CI session.

Any help is appreciated


I found the way and it may not be the best.

I'm using smarty templating engine, and inside my libraries/smarty_parser.php inside parse function I have the following:

function parse($template, $data='', $return = false){
        if ($template == ''){
            return false;

        $CI =& get_instance();

........ more stuff here -------


now whenever i want to check if the admin is logged in i simply do
{if $admin_logged)
more option for admin here
Please if there is a better way to do it, please let me know, but I'm posting here in case anyone else is wondering.

If you used to install smarty in CI, or if you have a line like this somewhere for smarty:
//register Smarty resource_name 'ci'
        $this->register_resource('ci',array($this, 'ci_get_template', 'ci_get_timestamp','ci_get_secure','ci_get_trusted'));

then you are able to access most CI stuff from within smarty templates.

CI Session, you must either autoload session, or load it from the controller where it loads the view template.

Access segment:

You can access almost everything from smarty templates. If you get an error, be sure to load the helper or library.

I hope this will help somebody who is looking for something like that, like I did.



I'm trying to do it but I don't know how ..

Someone can help me what to do exactly ?
(I want to access code igniter session in my smarty file )

Did you tried my last reply? That's what I have done and it worked.


I don't have any smarty_parser file ..

I'm using this :

Edit : Resolved

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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