samedi 10 octobre 2015

Session variable is not clearing in Laravel using Route Redirect with

I'm using Laravel 5.1 and Zizaco/Entrust for roles & permissions. Here i'v an issue while clearing the session variable. As per my understanding with() method – its purpose is to add an error message or some input data only for that particular redirect and only for one page. In my case it is redirecting properly to the dashboard but the session message is existing even after refreshing the page.

Route

<?php
  Route::group(['middleware' => 'auth'], function () 
  { 
        Route::get('dashboard', function () { 
          return view('dashboard');
        });
       Entrust::routeNeedsPermission('add_item', 'Create_Item', Redirect::to('dashboard/')->with('message', 'You Dont have peremissions..'), false );
       Route::get('add_item', 'ItemController@create');
  });

View

@if(Session::has('message')) 
  <p class="alert {{ Session::get('alert-class', 'alert-info') }}">{{     Session::get('message') }}</p>
  {{Session::forget('message')}}
@endif

I tried dumping the session by refreshing the page. I have no idea why 'message' is still existing in the session data. Help me to figure out this issue



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire