Support the ongoing development of Laravel.io →
posted 9 years ago
Session

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

Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

sivakaza sivakaza Joined 5 Oct 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.