Is It possible to clear user browser old cookies (laravel_session , XSRF_TOKEN) from laravel 5.7

1.2k views Asked by At

I am trying to delete cookies from the user browser as I Have made some changes In my session.php file and i want to reflect those new changes in the user browser instead of their old stored cookies:

please check the screenshot

PHP artisan cache: clear
PHP artisan config: clear
deleting files from sessions folder 

I have tried these but no luck, Can anyone guide me regarding this issue Any help will be appreciated.

2

There are 2 answers

6
snitch182 On

If it is only your personal browser cookies you want to clear use the [x] in the screenshot you posted. It will delete your cookies.

To clear cookies from all the users of your website you need write some code that does detect and delete them when the users come to your website.

0
Nasir On
if (isset($_SERVER['HTTP_COOKIE'])) {
        $cookies = explode(';', $_SERVER['HTTP_COOKIE']);
        foreach($cookies as $cookie) {
            $parts = explode('=', $cookie);
            $name = trim($parts[0]);
            if (isset($_COOKIE[$name])) {
                //unset($_COOKIE[$name]);
                \Cookie::queue(\Cookie::forget($name));
                setcookie($name, null, time() -3600, '/', '.domainname');
            }
        }

    }

This is what I have done so far, It's working but I guess there will be a neat and cleaner way to do Thanks for your information stackoverflow.com/users/831532/snitch182