// Using Yii framework libraries Yii::app()->getSession()->add('username', 'JohnDoe'); // Traditional PHP method $_SESSION['username'] = 'JohnDoe';
// Using Yii framework libraries Yii::app()->getSession()->add('user', array( 'name' => 'John Doe', 'age' => 30, 'email' => 'johndoe@example.com' )); // Traditional PHP method $_SESSION['user'] = array( 'name' => 'John Doe', 'age' => 30, 'email' => 'johndoe@example.com' );In this example, we set a session variable named "user" with an array value that contains name, age, and email properties. The first code example uses the Yii framework method, while the second code example shows traditional PHP method. Overall, CValue setSession is a powerful method that allows developers to easily set session variables with specific values. It is part of the Yii framework package library, which is designed to increase productivity and simplify web application development.