dou4064 2015-07-11 07:45 采纳率: 100%
浏览 21

无法在第二个函数中获取会话内容

I am having some issues with sessions.

In the first function queue, I save the session entries I can print this out from this function, so I can see its being set correctly.

In the function remove, I try and save this entries session into a variable and I get the error that entries is an undefined index.

Does anyone have any ideas what I am doing wrong here?

function queue() 
{
    session_start();

    $status = 'Awaiting Moderation';
    $channel = '1';

    // Find all entries in 'Gallery' channel with 'Awaiting Moderation' status
    $this->EE->db->select('entry_id')
                 ->from('exp_channel_titles')
                 ->where('status', $status)
                 ->where('channel_id', $channel);

    $query = $this->EE->db->get();      
    $entries = $query->result_array();

    $entries_count = count($entries);

    // Set count
    $_SESSION['entries_count'] = $entries_count;    

    // If entries found
    if ($entries_count > 0)
    {
        // Flatten entry ids array
        $entriesFlat = array();
        array_walk_recursive($entries, function($a) use (&$entriesFlat) { $entriesFlat[] = $a; });

        $entriesSerial = serialize($entriesFlat);

        // Save in session
        $_SESSION['entries'] = $entriesSerial;
    }

}

function remove()
{
    session_start();

    // Get session data + save into variable
    $entries = $_SESSION['entries'];

}
  • 写回答

3条回答 默认 最新

  • dtbc37573 2015-07-11 08:44
    关注

    You can only have one session and it should be at the top of your file.

    评论

报告相同问题?

悬赏问题

  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥15 关于超局变量获取查询的问题
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集
  • ¥15 在启动roslaunch时出现如下问题
  • ¥15 汇编语言实现加减法计算器的功能