Tuesday, April 4, 2017

Session doesn't save value with redirect-> "with" method laravel 5.2

When I put data like this:

$request->session()->put('123', '12345')

, session contains this value, but when I try to put data into session this way

$result = ['status' => 'Product has been updated']
return redirect('/admin/products/')->with($result);

Session doesn't contains it.

kernel:

    class Kernel extends HttpKernel
{

    protected $middleware = [
        \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
         \Illuminate\Session\Middleware\StartSession::class,
         \Illuminate\View\Middleware\ShareErrorsFromSession::class
    ];

    protected $middlewareGroups = [
        'web' => [
            \App\Http\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            \Illuminate\Session\Middleware\StartSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            \App\Http\Middleware\VerifyCsrfToken::class,
        ],

        'api' => [
            'throttle:60,1',
        ],
    ];

    protected $routeMiddleware = [
        'auth' => \App\Http\Middleware\Authenticate::class,
        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
        'can' => \Illuminate\Foundation\Http\Middleware\Authorize::class,
        'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
        'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
    ];
}

routes:

    Route::group(['prefix' => 'admin', 'middleware' => 'auth'], function () {
        Route::get('/', ['uses' => 'Admin\IndexController@index', 'as' => 'adminIndex']);
        Route::resource('/products', 'Admin\ProductController');
    });

I have red about changes in laravel 5.2 and that this problem may cause web middleware but i haven't it in my routes. Why session doesn't contain given status then?



via Batmannn

Advertisement