Question: What is this error:

```
Error 310 (net::ERR_TOO_MANY_REDIRECTS): There were too many redirects.

```

I use PHP CodeIgniter and library [SimpleLoginSecure](http://codeigniter.com/wiki/SimpleLoginSecure/), this is my code:

```
if ($this->session->userdata('logged_in')) {
    redirect('admin/index');
}

```

---

How can I resolve this error?

Regards

Answer: 
You should not use redirect() function in your class's \_\_construct().
My solution:

```
$self    = $_SERVER['PHP_SELF'];
$str2use = strrchr($self, '/');
$length  = strlen($str2use) -1;
@$fname  = substr($str2use, 1, $length);

if ($fname != "YOURPHPSCRIPT.php"){
    echo "<script>window.location='YOURPHPSCRIPT.php';</script>";
    exit;
}  

```