douchongbang6011 2014-09-10 12:56
浏览 49

symfony2会话持久性

This has been bugging me for a week now.

I cant seem to get a large php array to persist in the session over a page redirect.

for ($i=1;$i<$data['weeks'];$i++) {
    $instances[] = array(
        'start' => $startTime + ((86400 * 7) * $i),
        'end'   => $startTime + ((86400 * 7) * $i) + $duration,
        'venueId' => $data['venueId']
    );
}

$request->getSession()->set('addClass-1-instances', $instances);

return new RedirectResponse ($this->generateUrl(
    'class_add', array(
        'clubId' => $this->club->clubId,
        'step' => 4,
        'classType' => 1
    )
));

This works when the array is really small (1-10 elements) but fails when it is larger (1000 - 2000 elements).

If I dump out the session object after adding it, I can see that it is in the session attributes collection.

var_dump($request->getSession());

protected 'attributes' => &
    array (size=6)
        'addClass-1-instances' => 
            array (size=1560)
                0 => ...

But once the page is redirected, the session appears to be totally empty.

object(Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag)[487]
    private 'name' => string 'attributes' (length=10)
    private 'storageKey' => string '_sf2_attributes' (length=15)
    protected 'attributes' => &
        array (size=0)
            empty

We store our sessions in the database, and it works fine throughout the rest of the webapp. I've read all over the place and seen people talk about the session.save-dir php option, but am I not right to think this is irrelevant when using DB storage.

Help!

Not sure how to solve this. The session ids remain the same on both the pages, and theres no code that explicitly clears the session.

Not sure where to go not but here!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
    • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
    • ¥15 MATLAB中streamslice问题
    • ¥15 如何在炒股软件中,爬到我想看的日k线
    • ¥15 51单片机中C语言怎么做到下面类似的功能的函数(相关搜索:c语言)
    • ¥15 seatunnel 怎么配置Elasticsearch
    • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
    • ¥15 (标签-MATLAB|关键词-多址)
    • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
    • ¥500 52810做蓝牙接受端