Re: [SMARTY] Re: Smarty and Sessions

From: Date: Tue, 05 Jul 2005 11:21:10 +0000
Subject: Re: [SMARTY] Re: Smarty and Sessions
References: 1 2 3  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-12780@lists.php.net to get a copy of this message
* Jochem Maas <jochem@iamjochem.com> : > Matthew Weier O'Phinney wrote: > > * "Jim MacDiarmid" <jim.macdiarmid@comcast.net> : > > > I'm very new to Smarty so I'm hoping someone can help me. > > > > > > Can someone explain how the $smarty.session.user variable is set? Is this > > > something native to smarty or something unquie to the sample code I have? > > > > Smarty loads most of the superglobal variables (_GET, _POST, SESSION, > > I never realised Smarty made all the superglobals available - > seems like madness to me. > <snip> > > also SESSION/ENV/SERVER are for programmers not designers. again MO I do not use these often in my templates, but I *do* sometimes use the *presence* of one or more session keys to trigger content availability in the template: {if $smarty.session.user} display personalization {/if} Granted, on consideration, it would probably be better to assign such a key to the template *first*: <?php if (!empty($_SESSION['user'])) { $smarty->assign('userLoggedIn', true); } ?> {if $userLoggedIn} display personalization {/if} But sometimes the shortcuts are easier. Additionally, my content editors/designers are not putting in the Smarty elements, so I have a large degree of safety in this regards. And since the $_SESSION array is under the control of the script, it can be in large part trusted. However, I *never* use $_GET, $_POST, or $_COOKIE in my templates -- like you, it seems to me that that way madness lies. -- Matthew Weier O'Phinney Zend Certified Engineer http://weierophinney.net/matthew/

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