InvalidStateException in Laravel Socialite

                                         Laravel provides a simple way to authenticate with Oauth providers using Laravel Socialite. It supports authentication using Facebook, Twitter, LinkedIn, Google, GitHub, GitLab and Bitbucket. It is possible to get InvalidStateException errors on callback sometimes. If it occurs randomly out of nowhere it could also occur when you open your site without www. The solution is go to your www root and observe the file config/session.php. The default configuration in session Session Cookie Domain is ‘domain’ => null, change it to ‘domain’ => ‘yoursite.com’. Then clear cache using artisan command and ‘composer dump-autoload’. You should also delete your cookies from you browser. The InvalidStateException could also occur when you have other bugs in your code.