I guess this must be a PHP related question but since I have lacks …
ok so I’m trying to log a user then log him/her out then login another user and then logout again …
But it seems like my second attempt to logout the newly logged user fails
here is the code which should print 1111 but only prints 111 (it is code that I am actually using in unit tests but the results are the same)
$currentUser = Yii::app()->user;
$identity = new UserIdentity('admin','admin');
if($identity->authenticate())
$currentUser->login($identity);
// user should be logged in
echo !$currentUser->isGuest;
$currentUser->logout();
// user should be logged out
echo $currentUser->isGuest;
$identity = new UserIdentity('d.moity@km.fr','moity');
if($identity->authenticate())
$currentUser->login($identity);
// user should be logged in
echo !$currentUser->isGuest;
$currentUser->logout();
// user should be logged out
echo $currentUser->isGuest;
I have debugged so far that I know that the second time I try to logout my SEssion variables are not destroyed, I figure this has to do with the session id or something but I admit I need help
You should checkout the book Agile Web Application Development with Yii 1.1 and PHP5 which talks about a good way to implement the Yii framework with a User database.
I think a quick fix would be to UNSET your session vars b4 logging them in again maybe… check out the php.net site for the use on that