Only store session in database after login

I want to store a session in my database, but only when someone is loggedin. At this moment everytime I refresh a page, there is a new session created in the database. So, when I refresh the homepage 10 times, I’ve 10 records in the DB. I’ve tried to set ‘autoStart’ to false, however somehow my application seems to ignore this.

I just set the cookieMode to ‘none’, because of testing purposes. I want to set it to ‘allow’ when the application is in production mode.

'session' => array(

            'class' => 'CDbHttpSession',

            'autoStart' => false,

            'connectionID' => 'db',

            'sessionTableName' => 'session',

            'autoCreateSessionTable' => false,

            'cookieMode' => 'none',


Please let me know if I need to share more code snippts… I don’t really know which parts are relevant.