The Alert class can be used to display session based success or failed messages inside views. After a page refresh the message will be removed and the session will be unset.
In this table you'll find information about the different methods you can use and what kind of data can be passed as an argument.
Method | Arg | Type | Expect |
---|---|---|---|
message() | 1 | string | session name |
The session name should be set to success or failed.
<?php
namespace app\controllers;
use core\Session;
class ExampleController extends Controller {
public function example() {
Session::set('success', 'Session message');
redirect('/page to show the message');
}
}
Depending on the setted session name, different html classes will be shown.
<!DOCTYPE html>
<html lang="en">
<head></head>
<body>
<?php core\Alert::message('success'); ?>
</body>
</html>