CodeIgniter Forums
Session / pages seem to be loaded several times - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Session / pages seem to be loaded several times (/thread-19759.html)



Session / pages seem to be loaded several times - El Forum - 06-18-2009

[eluser]tommebasso[/eluser]
Hi, I'm really stuck with a problem concerning my sessions and page views.
I'm logging each page view in a db-table writing the controller, the function, page-title, session-id, timestamp, browser and ip into a record.
My application seems to work fine, but when I look at the records with the logging data I see that certain pages get loaded three or more times; or at least they get logged more times, because it doesn't seem that the browser really reloads the pages.

so here's a controller (simplified version):
Code:
class Motoren extends MY_Controller {

    function Motoren()
    {
        parent::MY_Controller();
        $this->load->model('Motoren_model');
        $this->load->model('Log_model');
    }


    function Details($id, $marke='', $pic=1)
    {
        $this->data['motor'] = $this->Motoren_model->get_motor($id);
        $this->load->view('page', $this->data);
        $this->Log_model->add(array('controller'     => 'Motoren',
                                    'subbereich'     => $this->data['motor']->mtyp,
                                    'function'         => 'Details',
                                    'txt1'             => $this->data['motor']->marke,
                                    'txt2'             => $this->data['motor']->modell));
    }

}

and here are some records of my log-table:
Code:
(page title)    (session id)                        (stamp)                    (browser)                    (IP)
name_of_motor     499e4dc67c2df58de99c12cf52459e4f      2009-06-18 08:57:49      Unidentified User Agent      66.249.71.117
name_of_motor     dd60b2602dbd8bf28ee7bc71b55ba396     2009-06-18 08:57:48     Unidentified User Agent     66.249.71.117
name_of_motor     773adaa9530a06730c41ac4af81a31c6     2009-06-18 08:57:48     Internet Explorer 7.0     193.171.69.65
name_of_motor     773adaa9530a06730c41ac4af81a31c6     2009-06-18 08:57:45     Internet Explorer 7.0     193.171.69.65

these are my session config settings:
Code:
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 0;
$config['sess_encrypt_cookie'] = FALSE;
$config['sess_use_database'] = true;
$config['sess_table_name'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 3000;

The function gets called only once per page created, I'm very sure of that. And I verified that the motor only got viewed once.

As you can see in the log-records, the session-id and browser change and the stamp differs (it's always about 1 to 3 seconds from one record to the next).
And now the fun thing: this happens quite often, but not every time.

I have google-maps and google-analytics in my page-view; can it be, that those javascripts trigger those extra Log_model->add-function-calls somehow?

I already searched the forum for session-problems, but didn't find anything that would be similar to mine or give me some hint where to look for the solution.

Anybody has any idea?