How to get session mobile in laravel

Posted 2 months ago by irankhosravi

I want to after registered a user name, age, mobile and ... get the session of mobile because in next page, I want to get mobile in input hidden.

Attention: I did not do session at all.

I think it's like this:


public function register(Request $request, User $user)
    $code = rand(10000,99999);
    $user = \App\User::create([
        'first_name' => $request->first_name,
        'last_name' => $request->last_name,
        'gender' => $request->gender,
        'mobile' => $request->mobile,
        'code' => $code,
     return redirect()->route('code')->with('mobile', $request->mobile);   

It redirect to this page.



<form action="{{ route('send') }}" method="post">
    {{ csrf_field() }}
    <input type="hidden" class="form-control" value="{{ session->mobile }}" name="mobile" id="mobile">
    <div class="form-group">
        <label for="code">کد</label>
        <input type="text" class="form-control" name="code" id="code">
    <div class="form-group">
        <button type="submit" class="btn btn-danger" id="btn-ok">OK</button>

Please sign in or create an account to participate in this conversation.