Skip to content
Advertisement

Get cookie on function boot ()

Good morning all.

Here I try to get cookies to be able to check if the user has them to be able to recreate a session for him.

But in the boot() I do not get the value of my cookie I get data but I do not know where it comes from!

//admincontroller

function public admin()
{
   Cookie::queue(Cookie::make('customer', 1, 5000));
   Cookie::get('customer');
   // value '1'
}

//AppProvidersAppServiceProvider.php

 public function boot()
{
    Cookie::get('customer');
    // value 'eyJpdiI6IlwvQnE1RW1RV3FBa0Y2dHBSOStWSXVnPT0iLCJ2YWx1ZSI6ImZRcWsyeHhqMUhxS01aaTFUY2dGSnZJM080NFwvOEVkUVR5Z0lsV3dIQ1Axa1RZMHFyNjh1U.............'
}

Could you help me? Can I put another part than in boot() a global function that is called all the time to check and refresh the session if necessary?

Advertisement

Answer

Hello everyone so here I post the answer for any people it might interest.

So actually I am going through a middleware to check if I have cookies and recreate a session.

The middleware I put in the kernel.php Web route after the others and everything works fine, because every time I call a route it checks that!

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement