title: Laravel - set session from form input
body: <p>I cannot display session value in my view. I only want to display it to see if it's correctly set inside the controller. Is it correctly set in controller? How can I check?
  I have this in view:</p>
  
  <pre><code>&lt;div class="panel panel-success"&gt;
                  &lt;form action="{{ route('get_table') }}" method="POST"&gt;
                      {{ csrf_field() }}
                      @foreach($tables as  $data)                   
                      &lt;button type="submit" name="tables" class="btn btn-primary" value="{{ $data-&gt;id }}"&gt;
                          {{$data-&gt;name }}
                      &lt;/button&gt;
                      @endforeach
                  &lt;/form&gt;
                  {{ Session::get('table_id') }}
              &lt;/div&gt;
  </code></pre>
  
  <p>This in ListController: </p>
  
  <pre><code>public function index() {
      $tables = DB::table('tables')-&gt;get();
      return view('welcome', compact('tables'));
  }
  
  public function getTable(Request $request) {
      $table_id = $request-&gt;get('tables');
      $request-&gt;session()-&gt;put('table_id', $table_id);
  }
  </code></pre>
  
  <p>And this in web.php routes:</p>
  
  <pre><code>Route::get('/', 'ListController@index')-&gt;name('get_table');
  Route::post('/', 'ListController@getTable');
  </code></pre>
  
  <p>I even tried </p>
  
  <pre><code>public function getTable(Request $request) {
      $request-&gt;session()-&gt;put('table_id', '1234');
  }
  </code></pre>
  
  <p>Nothing shows up in the view at  <code>{{ Session::get('table_id') }}</code></p>
  
  <p>What am I doing wrong?</p>