Laravel 5.4调用未定义的函数Session :: getMetadataBag() [英] Laravel 5.4 call to undefined function Session::getMetadataBag()

查看:79
本文介绍了Laravel 5.4调用未定义的函数Session :: getMetadataBag()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在5.3版中,Session :: getMetadataBag()可以很好地获取Session数据,但升级后由于调用未定义方法Illuminate \ Session \ Store :: getMetadataBag()而抛出错误.

In version 5.3, Session::getMetadataBag() was working good to fetch the Session data but after upgrade it is throwing error as Call to undefined method Illuminate\Session\Store::getMetadataBag()

Session :: all()不包含如下所示的上次使用记录:

Session::all() doesn't carry last use record like below:

array:4 [
    "_token" => "SQjQpOxCec5lal5tzFgW1FMtrcOaaIqjoii2fuCb"
    "_previous" => array:1 [
        "url" => "http://my-url"
    ]
    "_flash" => array:2 [
        "old" => []
        "new" => []
    ]
    "lang" => "en"
]

Session :: getMetaDataBag携带以下记录:

while Session::getMetaDataBag carries below record:

MetadataBag {#582
    -name: "__metadata"
    -storageKey: "_sf2_meta"
    #meta: & array:3 [
        "u" => 1485527838
        "c" => 1485527838
        "l" => "0"
    ]
    -lastUsed: 1485527838
    -updateThreshold: 0
}

是否有其他方法可以在Laravel 5.4中获取lastUsed记录?

Any alternative to get this lastUsed record in Laravel 5.4?

推荐答案

metadatabag实际上是Symfony的一部分.在Laravel 5.4中,会话组件被重构为不再依赖于Symfony,因此metadatabag消失了.您将需要自己实现此功能.

The metadatabag is actually part of Symfony. In Laravel 5.4, the session component was refactored to not depend on Symfony anymore, so the metadatabag is gone. You will need to implement this functionality yourself.

这篇关于Laravel 5.4调用未定义的函数Session :: getMetadataBag()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆