Confused in flash messages

$this->Flash->success(‘post added successfully’ [‘key’=>message’]);

what is meaning of key here? i cant understand with cakephp book please help
using key you can control where and what flash msg are rendered:

// In your Controller
$this->Flash->success('The user has been saved', [
    'key' => 'positive',
    'params' => [
        'name' => $user->name,
        'email' => $user->email

// In your View
<?= $this->Flash->render('positive') ?>

this is the default, cake use “flash” key if you dont specify the key

$this->Flash->set('The user has been saved.');
<?php echo $this->Flash->render(); ?>
1 Like