Q:

Joomla 2.5 home page redirect issue

I want to set joomla site to redirect visiting users to registration page if my cookie is not set.
I've put below code in top of the (after imports) template index.php file.
if (empty($_COOKIE["abc"])){   
    $app = &JFactory::getApplication();    
    $link = "index.php?option=com_users&view=registration";
    $app->redirect($link);
   exit();
}

URL is redirect but it is going in loop. so page not loading correctly. 
This is fire bug screen shot 

How to omit this loop ?
Thanks.

A:

Your problem because of your code. You put your code on top of page... your redirection to registration page is correctly but when page goes to registration page.. at that time this code also check because it is on top of index file.. so again redirect on registration page.
So, loop continue redirecting...then i think issue create.
Put condition on your code with cookies like below,
if (empty($_COOKIE["abc"]) && empty($_COOKIE['is_redirected']) && (new condition)){ 

new condition: above replace new condition with check your page is not login or register what you want.

