首页 > 解决方案 > 重定向到另一个页面时如何传递数据?

问题描述

我想在使用该数据重定向到另一个页面并在该页面中使用它时传递用户数据。

$mobile = (int) $request->mobile;

        $user = User::where('mobile',$mobile)->first();
        if ($user->count() > 0 && Hash::check($request->password, $user->password))
        {
            return redirect('/user_info')->with('user',$user);
        }

我想在其中使用用户数据的视图:

  <div class="row">
        <h3>Valnteer: {{ $user->name }}</h3>
    </div>

我得到的问题是:

未定义变量:用户

标签: phplaravel

解决方案


您需要将数据存储在会话中。

为了只传递一次数据,有一个概念叫做闪烁


推荐阅读