Eğer $ _SESSION sonraki sayfa isteği yanıp istediğiniz mesajları saklayabilirsiniz. Ben yöntemler raylar çalışmak tam olarak nasıl bilmiyorum ama umarım bu iki fonksiyon kullanım olabilir:
function flash_get()
{
// If there are any messages in the queue
if(isset($_SESSION['flashMessages']))
{
// Fetch the message queue
$messages = $_SESSION['flashMessages'];
// Empty out the message queue
unset($_SESSION['flashMessages']);
return $messages;
}
// No messages so just return an empty array
return array();
}
function flash_set($message)
{
// If the queue is currently empty we need to create an array
if(!isset($_SESSION['flashMessages'])) {
$_SESSION['flashMessages'] = array();
}
// Fetch the current list of messages and append the new one to the end
$messages = $_SESSION['flashMessages'];
$messages[] = $message;
// Store the message queue back in the session
$_SESSION['flashMessages'] = $messages;
}
Sadece () depolamak ve flash_get istediğiniz mesaj ile flash_set () diyorsun, sana bu diziyi geri vermek ve bir sonraki sayfa isteği üzerine kuyruğunu floş olacaktır.
Eğer çalışmak bu yöntemleri için her sayfa isteği ile session_start() çağrı emin olmak için de gerekir.