从 cakephp 外部访问 cakephp 会话(身份验证) [英] Access cakephp session (auth) from outside cakephp

查看:21
本文介绍了从 cakephp 外部访问 cakephp 会话(身份验证)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 CakePHP 网站,它有自己的登录系统,使用 Auth 组件.我想知道以下是否可行:

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 文件的内容(以防止没有帐户的人访问这些内容).我不能在那里使用 Auth,因为我在 Cake 的外部"......我不知道是否可能使用 $_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 应用程序文件夹系统之外.

Is this even possible? And yes, the php has to be outside the CakePHP app folder system.

有什么想法吗?

推荐答案

是的,您可以访问 cakephp 文件夹外的 cakephp SESSION.试试这个会话变量

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 会话(身份验证)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆