Re: [SMARTY] Re: Smarty and Sessions

Matthew Weier O'Phinney <[email protected]>
Newsgroups gmane.comp.php.smarty.general
Message-ID <[email protected]>
* Jochem Maas <[email protected]> :
> Matthew Weier O'Phinney wrote:
> > * "Jim MacDiarmid" <[email protected]> :
> > > 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/

-- 
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.