Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mvnobrega's avatar

Flash session disappears only after second reload

Maybe it's something simple, but I can't understand why my session only disappears after the second page reload. See how I'm doing it:

Component Vuejs:

export default {
      props: ['uploadfim'],

      },
        data(){
            return {


            }
        },
        methods: {
            enviado() {
                axios.post('/upload-success', {
                    

                })
                .then(response => {
                    location.reload();
                })
                .catch( error => {
                    
                });

            },
  
        }

My Blade:

<pet-media uploadfim="{{ session()->has('upload_fim') }}" ></pet-media>

My controler (upload-success):

public function uploadSuccess(Request $request)
    {
        session(['upload_success' => 'Anvio feito com sucesso!']);
    }

My Controler show page:

public function petMedia(Request $request, $petid)
    {

        $uploadfim = session('upload_success');

        if ($uploadfim) {
            session()->forget('upload_success');
            session()->flash('upload_fim', $uploadfim);
        }

            return view('auth.pet-media'); 
        
    }

I can't understand why it doesn't work. I need to do 2 reloads to disappear the session. I tried in another browser and in the anonymous tab, but the same thing happens. What could I be doing wrong?

0 likes
0 replies

Please or to participate in this conversation.