redirect('home', 'refresh'); SOMETIMES IT DO, AND SOMETIMES IT DON'T |
[eluser]cobolCowboy[/eluser]
:-) Hello everyone, I'm running CI v2.1.3, PHP v5.3.10, under a WAMP setup on localhost. Right now, I'm trying a redirect() in two places. Bear in mind that the URL helper is autoloaded. The redirect seems to work fine in the logout controller here... Code: class Logout extends CI_Controller However, the very same redirect in the login controller doesn't work at all, the URI doesn't change, and I'm left with a totally blank screen. Maybe a fresh pair of eyes can help here. Code: class Login extends CI_Controller BTW... Code: $config['base_url'] = 'http://localhost/'; .htaccess is in the www root and looks like this... Code: <IfModule mod_rewrite.c>
[eluser]nikokolev[/eluser]
Have a look here. I had same problem with pages that should refresh but don't and with the Shopping Cart class. http://ellislab.com/forums/viewthread/235184/ I don't know if this can be of any help in your case but the issue sounds pretty similar.
[eluser]cobolCowboy[/eluser]
Thank you nikokolev. Can someone please offer a list of the possible reasons why the redirect will not work? I would find that more useful than a wild goose chase. Or, some in-depth explanation of how to debug this matter. Apparently, I have no debugging skills on this platform. No more threads please. I need some educated hypotheseez.
[eluser]TheFuzzy0ne[/eluser]
What browser are you using? Have you tried clearing your cache? Have you confirmed that your path of execution is what you're expecting, and redirect isn't being skipped? Have you tried removing the second parameter to redirect? As far as I'm aware, not all browsers support it, so a location redirect might work better.
[eluser]cobolCowboy[/eluser]
Hello FuzzyOne, Thanks for getting back to me. I'm using chrome, FF, and IE8, same behavior on all three. Yes, and clearing the cache did nothing. Yes, inserted an echo statement directly ahead of the redirect, got the echo but not the redirect. Yes, tried all the permutations of the redirect, with "refresh", with "location", and without a second parameter. I even did a raw PHP header statement to no avail. I'm beginning to think that it might be server related. Are there any particular server or PHP.ini settings that I need to be cognizant of?
[eluser]TheFuzzy0ne[/eluser]
Not that I'm aware of. However, echoing anything before sending the header will break the redirect. The headers must be the first thing sent to the browser. Is it possible that something is sending data to the browser (perhaps an error in your code), before the headers are sent? Have you enabled logging and error reporting? Your log directory must be writable. To enable error reporting, place the following at the top of your index.php. Code: ini_set('display_errors', '1');
[eluser]cobolCowboy[/eluser]
Having said that, what happens when you do this... Code: $this->session->set_userdata($sessionData); ...does it not communicate with HTTP to manipulate the cookie?? I get header already written warnings all the time. I have yet to figure out why, or what to do about it.
[eluser]Suhas nazir[/eluser]
Just try not sure add ob_start(); on the first line of your controller page
[eluser]TheFuzzy0ne[/eluser]
That warning should tell you the filename and the offending line number. In most cases, it's normally a simply whitespace after the closing PHP tag. Since PHP doesn't care whether or not you have a closing PHP tag at the end of a file, it's considered good practice to just omit it, as it helps safeguard against this kind of problem.
[eluser]cobolCowboy[/eluser]
Nice try, but there are no closing PHP tags in my files. |
Welcome Guest, Not a member yet? Register Sign In |