doujiazong0322 2016-01-27 17:33
浏览 62

Laravel 5 Session不能可靠地持久化

I love this site, able to find answers to all my questions until now.

I have a two Ajax transaction process here, where in the first transaction the values entered are put into the Session, the second transaction retrieves values entered and the previous transactions values in order to know how to proceed. This statement does not appear to be reliable, but it works better than 90% of the time. Why is it not reliable? The transaction completes successfully, and the screen appears correctly formatted.

Session::put('previous', serialize($entry));

Example transaction A; User scans an item UPC, the transaction identifies the UPC 0587 as correct, creates $entry, and responds back to the user "Please put 0587 into tote 3334"

$entry = (object) ['type' => 'UPC', 'text' => '0587'];
Session::put('previous', serialize($entry));

Example transaction B; Users scans the tote, the transaction identifies tote 3334 as correct, then asks for the previous transaction entry

$previous = (object) unserialize(Session::get('previous', self::UNKNOWN_SERIAL));

Better than 90% of the time $previous equals what we want (UPC, 0587). Sometimes $previous equals the values from a prior transaction before transaction A. $previous would equal self::UNKNOWN_SERIAL on the first transaction after logon.

Why does Session::put(..) appear unreliable?

Any help would be appreciated.

  • 写回答

1条回答 默认 最新

  • dor2p0520 2016-02-03 23:47
    关注

    Turns out is was a serialization issue. Changed the storage of $entry between these two transactions using Request::session()->getId(); as part of the key. This has resolved the issue. Testing showed that other instream transactions using the same Request::session() caused this issue.

    评论

报告相同问题?

悬赏问题

  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失