title: How to store input in session Laravel
body: <p>I'm new in Laravel Here I am trying to post my input form in to a session but its not working I get this error without any message:</p>
  
  <pre><code>Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException
  </code></pre>
  
  <p>I found nothing, here I am sharing some of my code.</p>
  
  <p>My Controller:</p>
  
  <pre><code>&lt;?php
  
  namespace App\Http\Controllers;
  
  use Illuminate\Http\Request;
  use App\Category;
  use \App\Product;
  
  class ShopController extends Controller
  {
      public function index()
      {
          $categories = Category::with('products')-&gt;get();
          return view('shop.index', compact('categories'));
      }
  
      public function category($id)
      {
          $products = Category::find($id)-&gt;products;
          return view('shop.1', compact('products'));
      }
  
      public function addToShoppingCart(Request $request)
      {
          $request-&gt;session()-&gt;put('cart', 'id');
          $request-&gt;session()-&gt;put('cart', 'number');
  
          $request-&gt;session()-&gt;flash('status', 'Product is toegevoegd!');
          return redirect()-&gt;back();
      }
  }
  </code></pre>
  
  <p>My view:</p>
  
  <pre><code>@extends('layouts.app')
  
  @section('content')
      @if(Session::has('id', 'number'))
          &lt;div class="alert alert-success"&gt;
              {{Session::get('id', 'number')}}
          &lt;/div&gt;
      @endif
      @foreach ($products as $product)
          &lt;ul&gt;
              &lt;li&gt;{{ $product-&gt;name }}&lt;/li&gt;
              &lt;li&gt;{{ $product-&gt;description }}&lt;/li&gt;
              &lt;li&gt;{{ $product-&gt;price }}&lt;/li&gt;
              &lt;li&gt;{{ $product-&gt;amount }}&lt;/li&gt;
          &lt;/ul&gt;
          &lt;form method="post" action="{{url('categories\{id}')}}"&gt;
              @csrf
              &lt;div class="col-md-4"&gt;
                  &lt;label for="number"&gt;Aantal:&lt;/label&gt;
                  &lt;input type="number" name="number"&gt;
  
                  &lt;label for="id"&gt;Id:&lt;/label&gt;
                  &lt;input type="text" id="id" name="id" value= {{$product-&gt;id}}&gt;
  
                  &lt;button type="submit" class="btn btn-success"&gt;Add product&lt;/button&gt;
              &lt;/div&gt;
          &lt;/form&gt;
      @endforeach
      {{var_dump(Session::get('cart'))}}
  
  @endsection
  </code></pre>
  
  <p>My routes:</p>
  
  <pre><code>Route::get('/shop', 'Shopcontroller@index')-&gt;name('shop');
  Route::get('/categories/{id}', 'ShopController@category');
  Route::get('/cart/{id}', 'ShopController@addToShoppingCart');
  </code></pre>
  
  <p>I hope someone can help me out with my problem to put the input in the session of laravel.</p>