i try to use CDbHttpSession to store something so i configure the main.php file as
// application components
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
),
// uncomment the following to set up database
'db'=>array(
'connectionString'=>'mysql:host=localhost;dbname=mambo;',
'username'=>'root',
'password'=>'root',
),
'dbSession'=>array(
'class'=>'CDbHttpSession',
'connectionID'=>'db',
'sessionTableName'=>'test',
)
),
note that db component is the same that i use for the database of the application and it works. the table "prova" is not created (i don't create it because i don't know which fields it needs). so i try to use the default sqlite doing
// application components
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
),
// uncomment the following to set up database
'db'=>array(
'connectionString'=>'mysql:host=localhost;dbname=mambo;',
'username'=>'root',
'password'=>'root',
),
'dbSession'=>array(
'class'=>'CDbHttpSession',
)
),
the variables are created in the standard HttpSession, i'm sure because i try to print_r($_SESSION) i find my variables.
// application components
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
),
// uncomment the following to set up database
'db'=>array(
'connectionString'=>'mysql:host=localhost;dbname=mambo;',
'username'=>'root',
'password'=>'root',
),
'session'=>array(
'class'=>'CDbHttpSession',
)
),
i changed the main.php like above but i always find the variables in the $_SESSION and in runtime nothing is created (I imagine i should find a folder or a fileā¦).
to save something in the component i do for example:
<?php
// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'Mambo yii based',
'language'=>Yii::app()->session->itemAt('applicationLanguage'),
// autoloading model and component classes
'import'=>array(
'application.models.*',
'application.components.*',
'system.cli.commands.shell.*',
),
// application components
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
),
// uncomment the following to set up database
'db'=>array(
'connectionString'=>'mysql:host=localhost;dbname=mambo;',
'username'=>'root',
'password'=>'root',
),
'session'=>array(
'class'=>'CDbHttpSession',
),
),
);
as you can see I set the language of the application looking to a session variable, probably it initialize the dafault session and continue to use the default one instead of initialize the db session. I tried to put the language row after the components but nothing changes.