Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Diagnosing the cause of a redirect loop in a CodeIgniter app

Posted on 2014-03-02
4
570 Views
Last Modified: 2016-04-07
I seem to have a redirect loop in my app, and I'm trying to track down the cause.

My controller home.php is the default controller for my app, and contains:
	function index()
	{
		if (!$this->tank_auth->is_logged_in()) {
			dbglog('redirecting');
			redirect('/auth/login/');
		} else {

Open in new window


The dbglog() call is just debugging to a log file. When I add debugging to the auth controller login function, it doesn't get output.

The word "redirecting" is written to my log file 21 times before an error is displayed by Chrome. Firefox doesn't seem to detect the problem (the page doesn't load; it just keeps trying).

Is there some kind of logging I can turn on in CodeIgniter to figure out what's happening?

It's possible the issue is with Apache, in which case I'll need to try to find out what logging is done by that, and where it gets written to. I'm using a (shared) corporate Linux server.
0
Comment
Question by:Terry Woods
4 Comments
 
LVL 36

Accepted Solution

by:
Loganathan Natarajan earned 250 total points
ID: 39899534
Is there some kind of logging I can turn on in CodeIgniter to figure out what's happening?


ref. http://ellislab.com/codeigniter/user-guide/general/errors.html
0
 
LVL 35

Author Comment

by:Terry Woods
ID: 39899924
Thanks for the link. I suspect that logging needs to be manually added though, so it requires me to understand the problem that I don't fully understand. I will have a play with the log threshold settings though and see what happens.
0
 
LVL 43

Assisted Solution

by:Chris Stanyon
Chris Stanyon earned 250 total points
ID: 39900091
In the config.php file in the application/config folder, turn logging up to maximum - 4

$config['log_threshold'] = 4;

Don't leave this in place for too long because your log files (usually in application/logs) will get huge.

Also double check what's going on in your auth/login method - that may be causing the loop
0
 

Expert Comment

by:Jawad Abbass
ID: 41540747
I have solved this issue by setting the value of "$config['sess_encrypt_cookie']" to "TRUE"
In my case it’s due to sanitizing of cookie values by security class.
But Encryption of cookie data solves the problem.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How has this flight information been added to this website? 7 31
Text field validation on text fields used for multiple inserts 7 21
PHP Mail error 3 26
Ajax and PHP 9 29
If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question