JaquelineBrandao / yii

Automatically exported from code.google.com/p/yii
0 stars 0 forks source link

Session isn't started again when user was logged out and then logged in #935

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
<?php
class TestController extends CController {
    function actionTest(){
         echo 'before get '.session_id();
         echo '<pre>'.print_r($_SESSION, true).'</pre>';

         echo Yii::app()->user->getFlash('test');
         echo 'after get, before logout '.session_id();
         echo '<pre>'.print_r($_SESSION, true).'</pre>';

         Yii::app()->user->logout();
         echo 'after logout '.session_id();
         echo '<pre>'.print_r($_SESSION, true).'</pre>';

         $identity = new UserIdentity('sam', '123123');
         if(!$identity->authenticate()){
             echo 'wrooong!';
         }
         echo 'after login '.session_id();
         echo '<pre>'.print_r($_SESSION, true).'</pre>';

         Yii::app()->user->setFlash('test', 'test string');
         echo 'after setflash '.session_id();
         echo '<pre>'.print_r($_SESSION, true).'</pre>';
    }
}

Original issue reported on code.google.com by alexander.makarow on 15 Feb 2010 at 7:49

GoogleCodeExporter commented 9 years ago
Maybe add special property $preserveSession so session gets recreated after 
logout. 
Most of the time one don't need session after logout, so it may shouldn't be 
default 
behaviour to re-create session? Don't know.. For now I use simple fix: http://
www.yiiframework.com/forum/index.php?/topic/7077-setflashgetflash-problem/
page__view__findpost__p__37096

Original comment by keyboard...@gmail.com on 15 Feb 2010 at 10:08

GoogleCodeExporter commented 9 years ago
session is started automatically in CWebUser::init(). You should explicitly 
start the
session again in this case.

Original comment by qiang.xue on 20 Feb 2010 at 4:51