Yii Flash Messages

Here I added the source code to show the flash message. We can show single or multiple messages in yii flash method.


//Set Flash Message
Yii::app()->user->setFlash('success', "Row Inserted Successfully");
//Get And Display Message
// For Single Flash Message
<?php
if(Yii::app()->user->hasFlash('success')): ?>
    <div class="info">
        <?php echo Yii::app()->user->getFlash('success'); ?>
    </div>
<?php endif;?>

// Multiple Message
<?php 
foreach(Yii::app()->user->getFlashes() as $key => $message) 
{
    if ($key=='counters')
    {
        continue;
    }
    echo "<div class='flash-{$key}'>{$message}</div>";
}
?>