dpwle46882 2016-07-13 10:16
浏览 84
已采纳

Laravel会话数据传递

I don't understand how my data is directed through session using ->with.

For example I am doing a simple redirect with some data:

return Redirect::to('/event')->with('data', 'hello.');

Now, this code below works fine:

$data = Session::get('data');
echo $data; //it says hello

But this one NOT:

var_dump($_SESSION); //empty array

The var_dump gives me empty array, which means that session doesnt contain anything I guess. While the Session::get() has no problems with it. Why does that happen? Please explain it to me a little bit.

  • 写回答

1条回答 默认 最新

  • doupao1978 2016-07-14 11:33
    关注

    For security reasons Laravel uses its own custom session handler which doesn't populate $_SESSION superglobals with your session variables, so to work with laravel session you should only use Session facade's methods

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Pwm双极模式H桥驱动控制电机
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题