Welcome Guest, Not a member yet? Register   Sign In
What's wrong with redirect() func?
#1

[eluser]Roobiz[/eluser]
Hi guyz,

Since I develop with CI I never had the following problem.

I work with 3 hosting (localhost: for dev, dedicated server: for preproduction and shared hosting for production)

In many case I use redirect() function. Exemple login form on home page.

Code:
example code: the form is submit on user(controller)/login(method)
if($login)
{
    redirect('user/account');
}
else
{
    $this->session->set_flashdata('message', 'error login/pwd');
    redirect(); // redirect to home
}

pretty simple no?

So in localhost or preprod everything ok. Home is reloaded and I display error.
On production, nothing, the page is not reloaded.

If I check 'network' on Firebug I can see that:
localhost/preprod: user/login http response 302, then get home page response 200

On production: user/login http response 302 and thats all... It seems to use the browser's cache.

So it's work on prod when I'm disabled the browser cache.

I tried to set http response code to 200 in redirect func but it doesn't work.


What's wrong? Shared hosting? Code? ???

Thanks Smile
#2

[eluser]Roobiz[/eluser]
No idea Sad ?
#3

[eluser]mi6crazyheart[/eluser]
Is there any error coming from CodeIgniter or PHP... ?
#4

[eluser]bretticus[/eluser]
Since the redirect happens on a failed login on production, why not shoot us a link here so we can look with firebug ourselves?
#5

[eluser]Roobiz[/eluser]
You can see prod on http://bit.ly/aSbkFW

Try with cache activated (firefox) to clic on "connexion". Page is reloaded but it's the same. Then press F5. You have the error message.

Retry with cache disabled. It's work.

No php error.
#6

[eluser]bretticus[/eluser]
Clear your firefox cache and try to duplicate it. I, for one, do not see any problems or errors. :\
#7

[eluser]tkyy[/eluser]
maybe because you didn't pass an arg to the 2nd redirect() function. i use a function called base() that returns the base url for time's sake so i dont have to type $this->config->item('base_url'); all the time, so when i want to go back home i just

[code]
flash('incorrect username or password');
redirect(base());
[code]

i also use a flash() function to set flashdata.




Theme © iAndrew 2016 - Forum software by © MyBB