Start the session and connect the file FlashMessages.php
:
session_start();
require_once 'FlashMessages.php';
Create an object of the FleshMessages
class:
$flash = new FlashMessages();
If you want to set up a session, use the following method:
$flash->set('key', 'text');
You can also get a session by key or delete it:
$flash->get('key');
$flash->delete('key');
In order to use flash messages use this:
$flash->getFlashMessages('name');
Flash messages are deleted after the page is refreshed
<?php
session_start();
require_once 'FlashMessages.php';
$flash = new FlashMessages();
$flash->set('error', 'Login or password error');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<?=$flash->getFlashMessages('error');?>
</body>
</html>