安全和SEO友好的方法返回到PHP登录后返回上一个工作页面

时间:2022-10-20 10:09:24

What is the Secure and SEO friendly method for redirecting a user to the previous page he was working in PHP. I have seen people using GET variables to pass url, and I also know that sessions or $_SERVER['HTTP_REFERER'], can be used. But one of my friend told that $_SERVER['HTTP_REFERER'] is not safe If it is not safe how can we get the previous page URL

什么是用于将用户重定向到他在PHP中工作的上一页的安全和SEO友好方法。我见过人们使用GET变量传递url,我也知道会话或$ _SERVER ['HTTP_REFERER']可以使用。但我的一位朋友告诉$ _SERVER ['HTTP_REFERER']不安全如果不安全我们如何获取上一页网址

2 个解决方案

#1


Your Friend is right . $_SERVER['HTTP_REFERER'] is not guarantied to return previous page accurately. My recommendation is to use session and cookie to store the last page. Upon the login check for stored page URL and forward to your desired page and expire the cookie.

你的朋友是对的。 $ _SERVER ['HTTP_REFERER']无法保证准确返回上一页。我的建议是使用session和cookie来存储最后一页。登录后检查存储的页面URL并转发到您想要的页面并使cookie过期。

#2


You should pass the previous (relative or absolute) URL via GET (urlencode) to the login page, when you redirect to login.

当您重定向到登录时,您应该通过GET(urlencode)将之前的(相对或绝对)URL传递到登录页面。

The HTTP_REFERRER solution is not really secure.

HTTP_REFERRER解决方案并不十分安全。

#1


Your Friend is right . $_SERVER['HTTP_REFERER'] is not guarantied to return previous page accurately. My recommendation is to use session and cookie to store the last page. Upon the login check for stored page URL and forward to your desired page and expire the cookie.

你的朋友是对的。 $ _SERVER ['HTTP_REFERER']无法保证准确返回上一页。我的建议是使用session和cookie来存储最后一页。登录后检查存储的页面URL并转发到您想要的页面并使cookie过期。

#2


You should pass the previous (relative or absolute) URL via GET (urlencode) to the login page, when you redirect to login.

当您重定向到登录时,您应该通过GET(urlencode)将之前的(相对或绝对)URL传递到登录页面。

The HTTP_REFERRER solution is not really secure.

HTTP_REFERRER解决方案并不十分安全。