How to Create Session && Reporting Error using session?

I want to set new session for storing error notification.

I have trying to sett session using


this way is work, but I don’t sure are this is the correct way for creating session?

so I wanna to get this session to displaying in form action

how to get session back?

and after error session displayed, I want to unset this session, where I can unset this session?

I wanna to using method = "post" in form without a duplicating possible entry if I refresh page after inserted.

thank you for your attention…

For error notifications you can use CWebUser::setFlash().

For example you could do:

Yii::app()->user->setFlash('error', CHtml::errorSummary($model));

and then on the next user request you can test if the flash is set:

if (Yii::app()->user->hasFlash('error'))


   echo Yii::app()->user->getFlash('error');


A flash message is only available in the current and next user request (means you don’t have to delete the flash after you displayed it).

Regarding sessions, should read this.

oh… great… thank you sir. I will try to useing setFlas() and getFlash :slight_smile: