I've run into an issue where my session variables got cleared out after redirecting to another page or just refreshing the page using $this->redirect() or $this->referesh() respectively. I've been dealing with this issue for the last couple days. Therefore, any help would be very appreciated.
Here is my setup:
// protected/main.php
// I created my yii_sessions table and saw the data got populated in the session table
'session' => array (
'sessionName' => 'CouponSession',
'class'=> 'CDbHttpSession',
'autoCreateSessionTable'=> false,
'connectionID' => 'db',
'sessionTableName' => 'yii_sessions',
'autoStart' => 'false',
'cookieMode' => 'only',
'timeout' => 1800, // 1800/60 = 30 minutes; timeout is in seconds
),
// here is my table definition in the postgresql database
CREATE TABLE yii_sessions
(
id character(32) NOT NULL,
expire integer,
data bytea,
CONSTRAINT yii_sessions_pkey PRIMARY KEY (id)
)
// In controller, I am doing something like
$session = Yii::app()->session;
$session->add('key1','value1');
$session->add('key2','value2');
$this->redirect($this->createUrl('/home/'));
// in the protected/views/home/index.php
// I am trying to retrieve my session variable values
<?php
$session=Yii::app()->session;
$key1 =$session->get('key1');
$key2 =$session->get('key2');
// here I lost all my session variable values
// I have confirmed the session persists values fine if I am on the same view and controller
// However, after redirection, all session values disappears
?>
I've been searching in forums but I didn't find any suggested fix for this issue.
Please kindly point me to the right direction.
Thank you in advance.

Help














