Welcome Guest, Not a member yet? Register   Sign In
Randomly redirects
#1

[eluser]stuffradio[/eluser]
This is a weird problem I've been spending an hour trying to figure out.

It's a simple thing where it updates a field in the database.

The page:

Code:
<div class="clearfix">
  <h2 class="ico_mug">Modify Console</h2>
&lt;form action="&lt;?php echo site_url("ccenter/Console/updateConsole"); ?&gt;" method="POST" name="submitform"&gt;

      <div>
      &lt;input id="post_title" name="console_name" type="text" size="30" tabindex="1" value="&lt;?php echo $details-&gt;console_name; ?&gt;" />
      &lt;input type="hidden" name="id" value="&lt;?php echo $details-&gt;id; ?&gt;" />
      </div>
      <div>
      &lt;input type="submit" value="Update Console" /&gt;
      </div>

  &lt;/form&gt;    
    </div>

The console function

Code:
function updateConsole()
    {
        $this->load->model('consoles');
        $console_name = $this->input->post('console_name');
        
    $this->consoles->updateConsole($console_name, $this->input->post('id'));
    redirect(site_url("ccenter/Console/detail/$console_name"));
    }

The model function

Code:
function updateConsole($name, $id)
    {
        $data = array(
                      'console_name' => $name
                      );
        $this->db->where('id', $id);
        if ($this->db->update("igxpro_consoles", $data)):
            return TRUE;
        else:
            return FALSE;
        endif;
    }

It redirects sometimes to ccenter/Members/logout, but no where in my code do I have something for redirecting to that page... only in the header for a user to click on to logout. It's really weird.
#2

[eluser]tonanbarbarian[/eluser]
i suspect by your mention of redirection to a logout page that you have some sort of session that you use to control access to the site.

i suggest the issue is probably nothing to do with your code here, but with your authentication system, which you have provided not details about
#3

[eluser]stuffradio[/eluser]
Because I don't use the logout page for my session authentication. It simply destroys the session and redirects to the login page.
#4

[eluser]tonanbarbarian[/eluser]
all i can suggest is search your entire project for the logout page or redirects and see if any of them could be redirecting to the page in question and track back from there

my money is still on the authentication system
because the timeouts are "random" (no such thing really), the issue is most likely that the cookie or whatever is used for the session processing has expired and so the authentication system is causing the redirect.

is it your own hand coded authentication system or have you used a pre-existing library?
If you wrote the authentication system then I assume you know it well and I would be more willing to look elsewhere for a solution
but if you are using a third party authentication library then I would say have a good look at the code as it may be the cause of the issue.
#5

[eluser]stuffradio[/eluser]
It's my own system. Also, firebug gives me this error when it happens "Failed to load source for" and the url it gives me is the logout page.
#6

[eluser]tonanbarbarian[/eluser]
check your weblogs and see if that is the page it is really being redirected to, or it is something that firebug is doing
maybe even temporarily disable firebug and try to replicate the problem

if you are sure there is no code in your system that ever redirects to the logout page then maybe firebug is doing something silly

perhaps the page is partially being displayed and firebug is grabbing some of the text of the page, i.e. the logout link

try replicating the bug in other browsers

try installing the Live HTTP headers extension for firefox which records all request and you will be able to see exactly how the redirects are processing, what cookies are being passed back and forth etc
#7

[eluser]stuffradio[/eluser]
It does it in IE 9 as well. Live HTTP headers is not valid with FireFox 4
#8

[eluser]tonanbarbarian[/eluser]
then it is unlikely to be firebug that is the issue are we are back to some code somewhere that is redirecting to this page.

Look for every call to redirect and check them all
thats about all I can suggest
and checks the logs at the time of the issue and see what urls are being requested from the server
#9

[eluser]stuffradio[/eluser]
Thanks for all your help tonan. I'm not sure if I actually fixed it, but I must have tried over 20 times now and it hasn't happened again. I changed a hidden id with the name of "id" to "consoleid" and it hasn't done anything since. I'm praying that answered the problem! Big Grin

Edit: Knock on wood, right after I posted it happened again.

Edit 2: Since it's a small thing to do, I'll just make it so you delete the console and make a new one.




Theme © iAndrew 2016 - Forum software by © MyBB