Kohana 3.2 - 获取引荐来源网址
我正在尝试使用以下代码获取 Kohana 3.2 中的引用 URI:
$referrer = $this->request->referrer();
var_dump($referrer);
但是该函数返回 NULL,我希望它返回我离开以访问此页面的页面。
这是它应该如何工作的......如果是这样,我错过了什么或做错了什么?
这是在控制器中运行的。
此处的文档: http://kohanaframework.org/3.2/guide/api/Request#referrer< /a>
I'm attempting to get the referrer URI in Kohana 3.2 using the following code:
$referrer = $this->request->referrer();
var_dump($referrer);
However the function returns NULL, I'm expecting it to return the page I left to get to this one.
Is that how it should work... and if so what am I missing or doing wrong?
This is being run in the Controller.
Documentation here: http://kohanaframework.org/3.2/guide/api/Request#referrer
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我遇到的问题是由我的 Kohana 系统设置方式引起的。基本上我的系统中间有一个routeHandler,它控制用户采用的路线。在该脚本中,生成并执行了一个新请求。
发生的情况是在创建新的请求对象时,没有添加引用者 uri。我添加了以下代码,现在我可以在路由过程结束时从控制器获取引用 uri。
或者,atma 建议的更干净、更原生的解决方案如下:
The issue I was having was cause by the way my Kohana system is setup. Basically I have a routeHandler in the middle of my system which controls the routes users take. In that script a new request was generated and then executed.
What was happening was when creating the new request object it wasn't having the referrer uri added to it. I have added the following code and now I am able to get the referring uri from the controller at the end of the routing process.
Alternatively a cleaner more native solution as suggested by atma is the following: