![](/img/trans.png)
[英]How to redirect user to the referrer page after login is successful in jquery php?
[英]How to direct a user to the referrer page after login?
可以说该网站有一个用户帐户系统,该系统使用会话登录/验证等。
因此,可以说我向某人发送了一个链接domain.com/photos?id=3akK90,他们必须登录才能看到它。 因此,网站自然会要求他们登录,但是登录后将显示主页,因此我该怎么做,以便有一个推荐人,他们应该能够登录并直接转到该页面。
我假设您要重定向到登录名。 捕获他们最初访问的URL,将其存储在会话变量中,并在登录后将其重定向。
这是一个非常广泛的问题,也许研究$ _SERVER ['HTTP_HOST']会有所帮助。 当用户最初访问URL时,PHP将知道他们所访问的URL。 登录完成后,PHP可以使用Location标头重定向到该URL
在/照片上
check for user login
if no user login
save complete url in session
forward to /login.php
在/login.php上
when you catch the post
if the login is successfull
if that session variable exists and not null
forward to the complete url that was saved
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.