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
高洛峰2017-07-06 10:36:32
<?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
}
}
}
三叔2017-07-06 10:36:32
You can follow the following steps to troubleshoot:
Check whether the cookie
in the logged in post
request carries session
information;
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梦2017-07-06 10:36:32
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