Laravel Cookie (old)

Save cookie with redirect or response

use Illuminate\Support\Facades\Cookie;

// Save cookie for 120 minutes
$cookie = Cookie::make('table_id', $table_id, 120);
return redirect('/menu/' . $table->store_id)->withCookie($cookie);

Get cookie

    private function check_partner_order($req){
        $table_id = $req->cookie('table_id');
        if($table_id != false && is_numeric($table_id)){
            $table = PartnerTableM::find($table_id);
        }
    }

Reference:

  1. https://laravel.com/docs/5.8/requests#cookies
  2. https://laravel.com/docs/5.8/responses#attaching-cookies-to-responses