Welcome Guest, Not a member yet? Register   Sign In
URI variable changes(?) when set in a session

Dear CI community,

I have previously received great help from you when in trouble. Once more have I come across a problem where I can not find a solution.

I have tried searching the forum and google, and have also done a lot of debugging.

Please let me explain my issue and see if anyone can point me in the right direction.

I am making a step-by-step wizard for people who want to notify to a dog-competition. In the process of notifying, they have to fill in 3 forms with information about their hounds. I have divided the steps in 3 controllers. To keep track of the hound between the controllers, I want store an ID in a session. The core of the problem, is that sometimes the ID isn't stored, instead the word(?) "images" is stored. (the other session values, the default ones, are stored correctly)

I say sometimes because it seems to happen a bit random. It happens both on Firefox and Chrome. It seems to happen more often with Chrome.

When the correct value has been stored once, it all seems to work accurately, and change depending on what I pass to the controller.

This is my code for the first controller:

function edit_basic($houndID = FALSE)

//these first lines is added for debugging
        echo $houndID; //echoes correct houndID
        //$houndID = 52; //if uncommented, houndID in database is set to 52, not images

        $this->session->set_userdata('houndID', $houndID); //when I look in db, 'houndID' is set to 'images' - this is the core of the problem

        echo $this->uri->segment(3); //echoes the correct houndID
        echo $houndID; //echoes correctly again

//below is the code actually intended to use

        if( $houndID )
            if( $houndID != $this->session->userdata('houndID') )
                $this->Guides->set_current_as_max(); //handle the wizard-step-thing
            $_SESSION['houndID'] = $houndID; // I have also tried with PHP sessions, same problem, it says 'images' in the session, when retrieved in another controller (not when retrieved in this one though!)
            $this->session->set_userdata('houndID', $houndID);
            $houndID = $this->session->userdata('houndID');
        if( $guide = $this->Guides->connect() ) //this part is to keep track of the wizard-steps
            $data = $guide['data'];
            $redirect = $guide['redirect'];
            $data['lobjects'] = $this->Guides->get_guide_by_name('hound');
            $redirect = '';
        update_if_post('Hound', $_POST, $houndID, $redirect, 'hound_basic'); //starts with if($_SERVER['REQUEST_METHOD'] == 'POST) so it should not (and does not) do anything

        //these are set for the view
        $this->load->model('Breeds_model', 'Breeds');
        $data['breeds'] = $this->Breeds->get();
        $data['sub_title'] = 'Grunduppgifter';
        $data['title'] = 'Hund - grunduppgifter';
        $data['hound'] = $this->Hound->get_hound($houndID);

        session_write_close(); //have tried this when testing with PHP sessions
        standard_view('hound/edit_basic', $data); //helper to concatenate views

I am using the latest CI (1.7.2) and I am autoloading the session library. PHP Version 5.2.9.

If anyone could point me to where my problem could be, or where I can look to find a solution, I would be very glad!

Best Regards

Theme © iAndrew 2016 - Forum software by © MyBB