简体   繁体   English

登录php后返回上一页

[英]Back to previous page after login in php

I'm trying to modify the loginController and AuthenticatesUsers files so that there are two options once you log in: 我正在尝试修改loginController和AuthenticatesUsers文件,以便登录后有两个选项:

if you log in through the normal form that takes you to the predefined page as "home" and if you log in through the forms that force you to log in to perform an action this will take you back to that page. 如果您通过普通表单登录,该常规表单会将您带到预定义页面作为“主页”,并且如果您通过强制您登录以执行操作的表单登录,则会带您回到该页面。

How could this be done? 怎么办呢? I've seen a lot of related questions, but none of them try two options. 我看过很多相关的问题,但是没有一个尝试两个选项。

I modified the redirectPath variable and tried to overwrite some methods, but I don't know how to make the two options coexist. 我修改了redirectPath变量并尝试覆盖某些方法,但是我不知道如何使这两个选项共存。

You can add this function in LoginController instead of redirectTo variable: 您可以在LoginController中添加此函数,而不是redirectTo变量:

protected function redirectTo()
{
    if () {
        return 'previous url';
    }

        return 'home';
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM