session autoStart not working on certain sites

Hi,

hi have a big problem.

In my config I have the following set:




	   'session' => array(

			'autoStart'=>true,

                        // other stuff...

	   ),



In every view I have the following code:




	echo "<pre>";

	print_r($_SESSION);

	echo '</pre>';



When visiting cetain sites such as "index.php?r=site/login" or others…

I get the error: [php] Undefined variable: _SESSION

That means on some sites I get the error, on others I don’t!

Whats wrong?

I use Yii 1.8

THX

Andreas

Hi Andreas,

session_start() function dont fill your $_SESSION array it make a session instance and you can get id by session_id();




echo Yii::app()->session->sessionID; //output session id;

if you wont to set something to session


Yii::app()->session->add(mixed $key, mixed $value)

affter that you can check :




print_r( $_SESSION ); //you will see your output with key and value you setted

mhhh okay thx for reply…

I still don’t understand why the session variable $_SESSION is filled with values when visiting certain URLs and sometimes its not. I see no pattern.

When visiting site/login, $_SESSION is not set.

When visiting site/indey, $_SESSION is set

THX

Andreas