简体   繁体   English

在 CodeIgniter 4 Flashdata 显示代码再次重定向到同一页面中

[英]In CodeIgniter 4 Flashdata displaying code redirecting to again again in the same page

In the CodeIgniter 4, I am using Flashdata for displaying error or success messages in view page and I am using the below code:在 CodeIgniter 4 中,我使用 Flashdata 在视图页面中显示错误或成功消息,并且使用以下代码:

<?php
    if(session()->get("success")){
        echo session()->get("success");
    }
?>

It is not and as well as it redirect frequent in same page using this code!它不是,而且它使用此代码在同一页面中经常重定向!

use Flashdata instead of session .使用Flashdata代替session

Once you reload the page, flashdata will disappear重新加载页面后,flashdata 将消失

$session->setFlashdata('item', 'value');
# to rerive
$session->getFlashdata('item');

You can warp it with if conditions well. if条件好,您可以将其扭曲。

if($session->getFlashdata('item')){}

Read more Flashdata - in codeigniter.com阅读更多Flashdata - 在 codeigniter.com

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM