How to get session mobile in laravel

Posted 5 days 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:

RegisterController.php

public function register(Request $request, User $user)
{
    $code = rand(10000,99999);
    session->get('mobile')
    $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.

Code

code.blade.php

<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>
    <div class="form-group">
        <button type="submit" class="btn btn-danger" id="btn-ok">OK</button>
    </div>
</form>

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

Reply to

Use Markdown with GitHub-flavored code blocks.