Buboon
Buboon

Reputation: 405

Bug when storing sessions in the database (Yii 1)

I have project on yii 1 and when i use DB for saving sessions i received bug. For each query to the site in the database creates a new entry. I don't know why. Therefore I can not get a variable from the session, becouse after refrtsh page i have a new entry in db. What i am doing wrong? Table:

CREATE TABLE `wo_yiisession` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`expire` INT(11) NOT NULL,
`data` TEXT NOT NULL,
PRIMARY KEY (`id`),
INDEX `expire_idx` (`expire`)

) COLLATE='utf8_general_ci' ENGINE=InnoDB

session component setings:

'session' => array(
        'class' => 'CDbHttpSession',
        'connectionID' => 'db',
        'sessionTableName' => 'wo_yiisession',
        'timeout' => 3600 * 24 * 30,
        'autoStart' => 'false',
        'cookieMode' => 'only',
    ),

Upvotes: 0

Views: 363

Answers (1)

Maug Lee
Maug Lee

Reputation: 915

It looks like your ID field is wrong type. Proposed table structure is:

CREATE TABLE YiiSession
(
    id CHAR(32) PRIMARY KEY,
    expire INTEGER,
    data BLOB
)

See CDbHttpSession

Upvotes: 1

Related Questions