Welcome Guest, Not a member yet? Register   Sign In
Session variables in smarty with CI
#5

[eluser]dmitrybelyakov[/eluser]
What smarty features do you intend to use? After some exploration i (yet) see no way to acces session directly from smarty templates.
So you still need to pass session data to smarty template somehow.

You can do it in several ways:


1. In your controllers like this:

Code:
$data['session']=$this->session->userdata;
$this->smarty_parser->parse("smarty.php", $data);

Or if you don't whant to do it each time in your controllers, you can move this to your smarty wrapper class.

2. In your smarty wrapper (smarty_parser.php) like this:

Code:
function parse($template, $data, $return = FALSE)
    {      
        if ($template == '') return FALSE;
        $CI =& get_instance();
        
        /* here it goes */
        $data['session']=$CI->session->userdata;
        
        
       ...
    }

Then you can access all your session data in templates by using
Code:
{$session.session_id}


Hope that helps :-)


Messages In This Thread
Session variables in smarty with CI - by El Forum - 04-02-2009, 05:50 AM
Session variables in smarty with CI - by El Forum - 04-08-2009, 05:06 AM
Session variables in smarty with CI - by El Forum - 04-08-2009, 05:11 AM
Session variables in smarty with CI - by El Forum - 04-08-2009, 05:15 AM
Session variables in smarty with CI - by El Forum - 04-08-2009, 09:05 AM
Session variables in smarty with CI - by El Forum - 04-08-2009, 10:10 PM
Session variables in smarty with CI - by El Forum - 04-29-2009, 05:34 PM
Session variables in smarty with CI - by El Forum - 04-30-2009, 06:12 AM



Theme © iAndrew 2016 - Forum software by © MyBB