Re: [SMARTY] Smarty vs. session_name() & session_id()

From: Date: Wed, 16 Oct 2002 15:55:41 +0000
Subject: Re: [SMARTY] Smarty vs. session_name() & session_id()
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-6153@lists.php.net to get a copy of this message
On Tue, 2002-10-15 at 15:32, Michal Prinke wrote: > I've just encountered some strange Smarty behaviour (or maybe this is my > fault? I don't know...) > > I need to insert session name and session id somewhere in my template. > So I put {$smarty.session.name} and {$smarty.session.id} there; > both of them did not generate any output. They're not supposed to. Smarty doesn't provide a session id. > Then, I wrote a simple function: > > function smarty_function_sess($params, &$smarty) { > echo("name=" . session_name() . ", id=" . session_id() . > "<br>"); > } > > ...and called it from my template ({$sess}). No effect either. The name in the template should be: {sess}. Writing a function to do this seems a bit strange, you're not modifying or making any content. > I'm absolutely sure that I call session_start() in each of my PHP scripts, > I use various data from the $_SESSION array and they work well. > > > > The solution was to put this line in my PHP script: > $smarty->assign(array("sess_name", "sess_id"), session_name(), > session_id()); > > > What do you think, why doesn't {$smarty.session.id} work? > Does Smarty clear session data somehow? The last solution seems to be the best one. It's not always a good thing to rely on smarty to do all the assigning for you. Also smarty doesn't really have anything to do with session management, this should primarily happen in your php code. Manfred

« previous php.smarty.general (#6153) next »