[eluser]Colin Williams[/eluser]
Well, you should probably create or use a more robust library to handle such systems. I would recommend doing more than simply checking for the existence of a session variable. CodeIgniter includes a Session library, and there are several improvements in the Wiki to consider using as a base for your login system. The user library I use has an access method that lets you easily perform these types of checks:
Code:
if ($this->user->access())
{
// Do something for any logged in user
}
if ($this->user->access('modify content'))
{
// Do something for any user with 'modify content' permission
}
if ($this->user->access(NULL, 'user/login'))
{
// Do something for any logged in user, redirect to 'user/login' otherwise
}
As you can see, the method reads well and provides multiple uses to streamline code. I'd suggest trying something similar.