php - Jump to the page before login after logging in
阿神
阿神 2017-07-06 10:34:32
0
3
1225

laravel5.4 How do I return to the page before logging in after logging in? How do I maintain this state?
Please ask God for answers

阿神
阿神

闭关修行中......

reply all(3)
小葫芦
<?php

namespace App\Http\Controllers;

use Illuminate\Support\Facades\Auth;

class LoginController extends Controller
{
    /**
     * Handle an authentication attempt.
     *
     * @return Response
     */
    public function authenticate()
    {
        if (Auth::attempt(['email' => $email, 'password' => $password])) {
            return redirect()->intended('dashboard');  // 关键此处的intended
        }
    }
}
三叔

You can follow the following steps to troubleshoot:

  1. Check whether the cookie in the logged in post request carries session information;

  2. The AuthController that handles login requests has a field redirectPath, which represents the jump page after successful login. Check whether this value is correct;

过去多啦不再A梦

I don’t understand

laravel. Let’s talk about the idea of ​​​​implementing this function without the framework under normal circumstances

You can get the current url when jumping to the landing page. When jumping to the landing page, splice it into a get parameter of the landing page, as shown below:

Then when submitting the login information, determine whether the url parameter has a value, and then jump to the page before login

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!