search

Home  >  Q&A  >  body text

php - Jump to the page before login after logging in

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

阿神阿神2687 days ago1264

reply all(3)I'll reply

  • 高洛峰

    高洛峰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
            }
        }
    }

    reply
    0
  • 三叔

    三叔2017-07-06 10:36:32

    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;

    reply
    0
  • 过去多啦不再A梦

    过去多啦不再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

    reply
    0
  • Cancelreply