Codeigniter view file displayed before facebook login
===

I have successfully integrated facebook connect in my codeigniter application, but I have come across a weird glitch.

The process in my login controller as follows:

1. Check if user has facebook session
2. If user is logged into facebook and has already given permission, he should be redirected to his profile page on my application
3. If no session, or if the user is logged into facebook but no permissions given, the login form(view file) should be displayed with no redirect

The problem I am facing is, if a user has facebook logged in and already given permissions and if he accesses the login page, the login form is displayed briefly, and then after a second or two, he is redirected to his profile page. Why is the login form even displayed? After all the code `$this->load->view('login_form');` executes at the last line of the controller after checking all the above.

So right now, it occurs that the login_form view file is displayed first, and then it checks for facebook session and after that it redirects.



