Unsettled session in smarty
After I insert data into the database, I set up a session and then redirect the page to another page, on another page I will show a message, if the session was set to smarty, everything is fine.
{if $smarty.session.insert===true}
Thanks
{/if}
Now, how can I disconnect the session after I print my message?
+3
source to share
4 answers
You shouldn't be doing this in a template and smarty doesn't work for that. However, if you really need to do this, the only way I can see could be this:
{php}
unset($_SESSION['insert']);
{/php}
Anything you put between the {php} tags will be executed by smarty like a normal php script.
+2
source to share
In your php file where you display the smarty template, reverse it after the display function.
if(isset($_POST['postdata'])) {
$_SESSION['insert'] = 'success';
}
$smarty->display('test.html');
unset($_SESSION['insert']);
In the template file
{if isset($smarty.session.insert)}
{$smarty.session.insert}
{/if}
0
source to share