什么是在codeigniter中使用set

编程入门 行业动态 更新时间:2024-10-22 18:37:09
什么是在codeigniter中使用set_flashdata(what is the proper was to use set_flashdata in codeigniter)

当我尝试在方法中设置flash数据时,它在重定向后不存在。 这是一个例子:

function logout() { $this->session->set_flashdata('auth_msg', 'you have been logged out'); redirect('admin/login'); }

问题是当我在flashdata中检查auth_msg的值时,它不存在,并且用户指南并没有真正显示使用它时要使用的方法。 与我想做的事情一起使用的最佳方法是什么?

谢谢

When I try to set flash data in a method it doesnt exist after a redirect. Here is an example:

function logout() { $this->session->set_flashdata('auth_msg', 'you have been logged out'); redirect('admin/login'); }

Problem is when I check for the value of auth_msg in flashdata, it doesnt exist and the user guide doesnt really show what method is bet to use when using this. What is the best method to use with what I am trying to do?

thanks

最满意答案

原因是因为Flash数据使用会话。

你刚刚在你的logout()函数中销毁了会话(我猜)。

因此,这是您在应用程序中无法使用flashdata的单一位置

在其他地方尝试它,它应该像你编码一样工作。

The reason is because flash data uses the session.

You have just destroyed the session on your logout() function (I'm guessing).

Therefore this is the one single place you cannot use flashdata in your application.

Try it somewhere else and it should work as you have coded.

更多推荐

本文发布于:2023-07-17 07:44:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1141149.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:是在   codeigniter   set

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!