问题描述
我有一个CakePHP的网站,使用验证组件它自己的登录系统。我想知道,如果以下是可能的:
I have a CakePHP website with its own login system using the Auth component. I would like to know if the following is possible:
一个用户登录并浏览该网站。在一个点上,他可以点击打开一个外部的PHP文件的链接。随着外部我的意思是,它可能是在同一台服务器上的其他文件夹,但CakePHP的应用程序文件夹之外。
A user has logged in and is navigating the website. At one point, he can click a link that opens an external php file. With external I mean that it could be in another folder of the same server, but outside the CakePHP app folders.
在棘手的事(对我来说)是只显示PHP文件的内容,如果用户登录(以prevent没有人访问这些内容的帐户)。因为我是外蛋糕我不能使用身份验证有...如果可能使用$ _SESSION我不知道,但我不知道该怎么...
The "tricky" thing (for me) is to only show the contents of that php file if the user is logged in (to prevent someone without an account accessing those contents). I can't use Auth there because I'm "outside" Cake... I don't know if maybe using $_SESSION, but I don't know how...
这甚至可能吗?是的,在PHP已经成为CakePHP的app文件夹系统之外。
Is this even possible? And yes, the php has to be outside the CakePHP app folder system.
任何想法?
推荐答案
是的,你可以访问CakePHP的文件夹外CakePHP的会议。试试这个会话变量
Yes you can access the cakephp SESSION outside cakephp folder. try this session variable
$_SESSION['Auth']
如果它存在,然后检查用户在这里
if it exists then check for user here
$_SESSION['Auth']['User']
这篇关于从外部访问CakePHP的CakePHP的会话(AUTH)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!