Tuesday, April 10, 2018

Laravel redirect to local referer after login - development

Laravel redirect to local referer after login

Trying to make redirect this way:

in LoginController add function redirectPath

public function redirectPath()
    {
        if (method_exists($this, 'redirectTo')) {
            return $this->redirectTo();
        }

        return property_exists($this, 'redirectTo') ? $this->redirectTo : '/home';
    }

and redirectTo()

public function redirectTo(){
        return '/dynamic_url';
    }

How can I set my ‘/dynamic_url’ to path that I came from


If add

$this->localReferer = app('IlluminateRoutingUrlGenerator')->previous();

It defines backurl correct, but when I submit login, page reloads and referer changed to ‘/login’

also tried to set cookie in __construct()

use Cookie;
...
Cookie::make('localreferer', $this->localReferer, 60);

and this does not create a cookie



from Laravel Questions and Answers https://laravelquestions.com/laravel/laravel-redirect-to-local-referer-after-login/
via Lzo Media

No comments:

Post a Comment