dongyan5141 2019-03-07 11:52
浏览 25

Code Igniter Flashdata在重定向后并不总是保留值

So this is a really weird one.

I have recently discovered Code Ignitor's flash data, which is exactly what i need.

However, I am noticing that sometimes I experience issues with it. Splitting it right down to the barebones(function one does literally nothing more than this except using real data, and function two does nothing more before fetching flash data, which is why I am confident I can reduce them down to this).

controller_one :

function one()
{
  $data['foo'] = 'bar';
  $this->session->set_flashdata('extra_data', $data);
  redirect('controller_two/two');
}

controller-two :

function two()
{
  if($this->session->flashdata('extra_data'))
  {
    var_dump($this->session->flashdata('extra_data'));
  }
}

The third file is just a static page with a static link to controller_one/one say index.

Now if i go index and click the link, it will correctly redirect and dump the data - as expected.

Now - and this is where it gets weird. If I go to the index - wait 10minutes + then click the link, it redirects but the flashdata is empty(NULL).

I really don't see how waiting on a static page to click a static can affect what is happening during the redirect between the two functions - causing loss of flash data, as that flashdata isn't even set until that link is clicked and the redirect happens immediately after that in both cases.

I have also tried to var_dump($this->session->flashdata('extra_data')); die; just before the redirect, and in both cases the data is set and correct - no difference, so it must be being lost during the redirect itself - I just can't comprehend how a wait before that influences that, but it must be - somehow.

It's fairly easy for me to work around, using standard sessions or whatever, but as flash data does exactly what I want, it seems more appropriate to use this - it's just not working if the user lingers on the page before it's set.

So any theories as to why, or better yet solutions, would be greatly appreciated.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 三种调度算法报错 有实例
    • ¥15 关于#python#的问题,请各位专家解答!
    • ¥200 询问:python实现大地主题正反算的程序设计,有偿
    • ¥15 smptlib使用465端口发送邮件失败
    • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
    • ¥15 对于squad数据集的基于bert模型的微调
    • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
    • ¥20 steam下载游戏占用内存
    • ¥15 CST保存项目时失败
    • ¥20 java在应用程序里获取不到扬声器设备