Yii Framework Forum: Session Problem - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Session Problem Rate Topic: -----

#1 User is offline   Apy 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 19-February 12

Posted 06 February 2013 - 12:17 PM

I'm working on shopping cart function, when I try to use session to store same data, NO data stored even using CHttpSession or CDbHttpSession.

Here are my code.

config
session' => array(
            'class' => 'CDbHttpSession',
            'connectionID' => 'db',
            'autoCreateSessionTable' => false,
            'autoStart' => false,
        ),


controllor
$session = Yii::app()->session;
                $session->open();
                $session->clear();
                foreach ($_POST['order'] as $item => $quantity) {
                    if ($quantity != '' && !is_null((int)$quantity)) {
                        if ((int)$quantity > 0) {
                            $session[$item] = (int)$quantity;
                        }
                    }
                }
                CVarDumper::dump($session->toArray(), 10, TRUE);
                $session->close();
                $session = Yii::app()->session;
                $session->open();
                CVarDumper::dump($session->toArray(), 10, TRUE);
                $session->close();

output
array
(
    2 => 1
    1 => 1
) array()


I don't know where the problem are. Are there any php config / app config may affect yii session function?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users