Re: [SMARTY] Newbee Question about how smarty works

From: Date: Mon, 10 Nov 2003 22:12:52 +0000
Subject: Re: [SMARTY] Newbee Question about how smarty works
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-10517@lists.php.net to get a copy of this message
Inside my template I would like to show different templates depending on if they have logged into the site or not.
I actually just asked the same question. Zoran and Onno were both very kind to respond (thank you guys again), if you can look up the archives there is sample code provided, the title is "Authentication with Smarty".
Do I check if the user is logged in from my index.php file than call the related template ie loginbox or user logged in links and save this output to a var.
Although I got excellent answers, I did something slightly different. My templates all call up the same header and footer so they all look the same, so what I did is check in my index.php if they are logged in, and if not required a security.php page that sends them a login template and processes login info. When they manage to fake a user and password correctly: $_Global[loggedIn] = "yes". Then I use the referer to send them back to where they wanted to go. I am looking for a better solution than using the referer because that could fail if their app doesn't suport it, I can think of one other solution but it would require naming every php page at the top and using that variable to send people to where they should go. If anyone has an interesting solution please share. I think this works better than putting the security in the template, because this way designers can't screw it up : ) Vonleigh Simmons [vanlei] San Francisco, CA <www.illusionart.com/pi/>

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