Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Safest way to redirect in smarty tpl

Tags:

php

smarty

I have this code below that I want to redirect them to home if they are logged in, but I just don't know how to go about it.. what is the best way to redirect a user, the fastest and best way overall inside a tpl file?

{if isset($smarty.session.user.id)} redirect here? {/if}

How can I do this? and what is the best way...


1 Answers

The best way is not doing it in a smarty template, but on the php script. If for some reason you can't do it, use javascript inside the {if}, i.e.

window.location = "http://www.yoururl.com";
like image 63
Borgtex Avatar answered Jan 20 '26 21:01

Borgtex