Asked  9 Months ago    Answers:  5   Viewed   116 times

I'm using Laravel 5.4 and Socialite so my users can log in with Facebook.

My website works with subdomain,

The Facebook URL redirect for the callback login has to be absolute so I set


public function redirectToProvider()

        $_SESSION['originalURL'] ="";

        return Socialite::driver('facebook')
            ->scopes(['rsvp_event', 'public_profile'])


 public function handleProviderCallback(SocialAccountService $service)
        $user = $service->createOrGetUser(Socialite::driver('facebook')->user());
        // $user->token;

        Auth::login($user, true);

        $originalURL = $_SESSION['originalURL'];

        return redirect()->to($originalURL);


When I am in the route login/facebook I can view the original URL with HTTP_POST

When I am in the route login/facebook/callback the HTTP_POST is since the URL of the redirection is I tries to save the URL in a session var but $_SESSION is empty.


How I can do to get the original url after the facebook login callback redirection. ? So if I started the login process with I'm redirected to and then I get the save url to be redirected


'cookie' => 'laravel_session',

    | Session Cookie Path
    | The session cookie path determines the path for which the cookie will
    | be regarded as available. Typically, this will be the root path of
    | your application but you are free to change this when necessary.

    'path' => '/',

    | Session Cookie Domain
    | Here you may change the domain of the cookie used to identify a session
    | in your application. This will determine which domains the cookie is
    | available to in your application. A sensible default has been set.

    'domain' => env('SESSION_DOMAIN', ''),

    | HTTPS Only Cookies
    | By setting this option to true, session cookies will only be sent back
    | to the server if the browser has a HTTPS connection. This will keep
    | the cookie from being sent to you if it can not be done securely.

    'secure' => env('SESSION_SECURE_COOKIE', false),

    | HTTP Access Only
    | Setting this value to true will prevent JavaScript from accessing the
    | value of the cookie and the cookie will only be accessible through
    | the HTTP protocol. You are free to modify this option if needed.

    'http_only' => true,



The key was not to use $_SESSION but session(['city' => 'paris']); and session('city') to retrieve the value.

Wednesday, March 31, 2021
answered 9 Months ago

After a long search, the solution is to remove the profile from scopes in vendorlaravelsocialitesrcTwoGoogleProvider.php

protected $scopes = [
Friday, May 28, 2021
answered 7 Months ago

You can use a named route to solve this issue:

Lets make a named route like this:

For Get

    'uses' => 'UserController@getAdditionalFields',
    'as'   => 'user.getAdditionalFields'

For post

    'uses' => 'UserController@postAdditionalFields',
    'as'   => 'user.postAdditionalFields'

So we can now ensure Laravel uses the right route by doing this

return redirect()->guest(route('user.getAdditionalFields'));

Also note that its not possible to redirect a POST because Laravel expects form to be submitted. SO you can't do this:

return redirect()->guest(route('user.postAdditionalFields'));

except you use something like cURL or GuzzleHttp simulate a post request

Saturday, May 29, 2021
answered 7 Months ago

Simply fetch the data using file_get_contents function and process the retrieved data.

use File; 

create a helper method to get the avatar

function getSocialAvatar($file, $path){
    $fileContents = file_get_contents($file);
    return File::put(public_path() . $path . $user->getId() . ".jpg", $fileContents);

replace $user->getAvatar()

with the helper method

getSocialAvatar($user->getAvatar(), 'path')

Saturday, May 29, 2021
answered 7 Months ago


The Laravelcollective/html has been updated to Laravel 5.4 but there is no any changes in the documentation till now. If you want to see the pull request it is right here:

Just use:

composer require "laravelcollective/html":"^5.4"


composer require laravelcollective/html

If you don't want to specify the version and get the same latest version of LaravelCollective.

Older Issue:

Laravelcollective/html v5.3.0 requires Laravel 5.3 and not yet supports Laravel 5.4.

The laravelcollective/html v5.4 is under open issue:

It could be merged any time.

Just have an eye on it.


Alternatively you could use maddhatter's git repository as he had done some changes that is not yet provided in repository.

Just add it into your composer.json

"repositories": [
            "type": "vcs",
            "url": ""
"require": {
     "laravelcollective/html": "5.4.x-dev",

and run

composer update

Or, if you don't need those changes you could follow Cerlin Boss answer

Sunday, September 26, 2021
answered 2 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :