Here are the code of my login page where the login script checks for the authenticity of the user and then redirects to inbox page using header function.
I encountered this issue today. the issue has to do with the $config['base_url'] . I noticed htpp://www.domain.com and http://example.com was the issue. to fix , always set your base_url to http://www.example.com