skip to Main Content

How are you guys?
In Laravel 11 how many do I try to put sessions for the shop’s cart by Api routes, the sessions don’t store!
Do you Have a solution for it?
even in Laravel 11 kernel.php removed!
now for the cart’s session should I use a route in web.php?

2

Answers


  1. By default, your application’s routes are configured and loaded by the bootstrap/app.php file:

    <?php
     
    use IlluminateFoundationApplication;
     
    return Application::configure(basePath: dirname(__DIR__))
        ->withRouting(
            web: __DIR__.'/../routes/web.php',
            commands: __DIR__.'/../routes/console.php',
            health: '/up',
        )->create();
    
    use IlluminateSupportFacadesRoute;
     
    ->withRouting(
        commands: __DIR__.'/../routes/console.php',
        using: function () {
            Route::middleware('api')
                ->prefix('api')
                ->group(base_path('routes/api.php'));
     
            Route::middleware('web')
                ->group(base_path('routes/web.php'));
        },
    )
    
    Login or Signup to reply.
  2. You can use the session() helper functions

    On the blade:

    @if(session(‘cart’))

    @endif

    On the controller:

    session()->get(‘key’);

    session()->put(‘key’);

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search