Yii::app()->session->add(‘product’, $productId);
Yii::app()->session->get(‘product’);
Yii::app()->session->remove(‘product’);
Yii::app()->session->add(‘product’, $productId);
Yii::app()->session->get(‘product’);
Yii::app()->session->remove(‘product’);
2 Comments
Hello,
I have assigned an array to a session variable.
Now I want to unset the array key. How can I perform this.
What I was trying was:
unset(Yii::app()->session[$variable][$key]);
it gives error.
Can you please suggest me the way to perform this action.
Any help will be highly appreciated.
Regards
You can try the following
Yii::app()->session[$variable][$key] = null;