Home > php教程 > php手册 > THINKPHP登陆并返回上一页方案(2)

THINKPHP登陆并返回上一页方案(2)

WBOY
Release: 2016-06-07 11:35:41
Original
1409 people have browsed it

之前写过一篇,参见:http://www.thinkphp.cn/code/1530.html,现在想想当时的实现方案很繁琐
参考TP官网实现登陆并返回上一页的方案,基本的实现思路是获取到HTTP_REFERER来源URL,并保存在cookie中,登陆后跟据cookie判断并决定跳转到那个页面
源码如下:

这里要做一个逻辑判断,是登陆页或退出页则不记录Cookie
使用parse_url($_SERVER['HTTP_REFERER'],PHP_URL_PATH);取得来源页面路径,这里你可以跟据路径来和U方法实现对比判断cookie('referer',$_SERVER['HTTP_REFERER'],"expire=3600&path=/&prefix='think_login-''');登陆后可以使用:cookie('referer') //取值并跳转以上只是本人浅见,也希望TP官方能给出实例,不足之处请谅解,欢迎讨论

AD:真正免费,域名+虚机+企业邮箱=0元

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template