Welcome Guest, Not a member yet? Register   Sign In
Simple Question - Best way to check for login status
#1

[eluser]PoetaWD[/eluser]
Hello All,

I am very new to PHP and programming...

I am developing a application where to enter a page the system checks if the user is logged in or not...

My question is not regarding that...

The question I have is about how is the best way of doing it...

Is it safe to do like this:

Code:
function check_login
{
   if(!$this->dx_auth->is_logged_in())
   {
      redirect('welcome');
   }
}

function index
{
   $this->check_login();
  
   //... THE REST OF MY CODE

}

The way I AM DOING IS THIS,

Code:
function index
{
   if(!$this->dx_auth->is_logged_in())
   {
      //... THE REST OF MY CODE
   }
   else
   {
      redirect('welcome');
   }
}

I am sure this way is safe... All I want to know, to cleanup my code is if that other way is also safe.... or users can prevent not to be redirected....

Thanks in advance

Gabriel


Messages In This Thread
Simple Question - Best way to check for login status - by El Forum - 04-24-2010, 09:46 PM
Simple Question - Best way to check for login status - by El Forum - 04-24-2010, 09:55 PM
Simple Question - Best way to check for login status - by El Forum - 04-24-2010, 11:08 PM
Simple Question - Best way to check for login status - by El Forum - 04-24-2010, 11:40 PM
Simple Question - Best way to check for login status - by El Forum - 04-25-2010, 12:30 AM



Theme © iAndrew 2016 - Forum software by © MyBB