跨文件夹的 phpbb 会话
我在位于 myWebSite.com/forum 的网站中使用 phpBB (2.0.22)
我正在 myWebSite.com/otherForders 中创建一些其他页面
我想要的是检查一个人是否登录到 myWebSite.com /forum 当他们在 myWebSite.com/otherForders 时
想知道这是否可能。
我已经尝试过 session_start(); print_r($_SESSION); 在 myWebSite.com/otherForders/index.php 中,我得到的只是 Array ( )
(一个空数组)。
有人有解决办法吗? 谢谢。
I'm using a phpBB (2.0.22) in a website, located at myWebSite.com/forum
I am creating some other pages in myWebSite.com/otherForders
What I want, is to check whether a person in logged into myWebSite.com/forum when they are in myWebSite.com/otherForders
Wondering if that's possible.
I've tried session_start(); print_r($_SESSION);
in myWebSite.com/otherForders/index.php and all I get is Array ( )
(an empty array).
Anyone with a solution?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该将您的板与您的代码集成,
这是示例 ::
然后使用
$userdata['username'], $userdata['user_id'] & ETC。
$userdata 具有数组,其中包含来自登录用户的董事会的 users_table 的值。
You should integrate your board with your code
Here is sample ::
Then use
$userdata['username'], $userdata['user_id'] & etc.
$userdata has array with values from users_table for your board for logged in user.
会话变量将无法以这种方式访问。您的 phpbb 的会话 cookie 存储在
myWebSite.com/forum
中,当您访问forum
目录之外的页面时,即(otherForders)
会话myWebSite.com/forum
在那里不可用,并且将启动一个新会话,这显然是一个空白数组,直到您分配一些值并且该会话的会话 cookie 存储在myWebSite.com/otherForders
。您必须告诉 php 将会话保存在根域(
myWebSite.com
)上,以便会话在所有其他目录中可用。您可以使用
ini_set
来完成此操作。您必须在调用
session_start()
之前放置ini_set
。我不知道 phpbb 是否提供任何管理界面来更改会话 cookie 域值。你应该检查 phpbb 是否提供了这个。ini_set('session.cookie_domain','.myWebSite.com');
您也可以尝试
The session variable will not accessible in this way. The session cookie of your phpbb is stored at
myWebSite.com/forum
and when you visit pages out offorum
directory ie(otherForders)
the session ofmyWebSite.com/forum
will not available there and a new session will be stared which is obviously a blank array until you assign some values and session cookie for this session is stored atmyWebSite.com/otherForders
.You have to tell php to save session on root domain which is
myWebSite.com
so that session will be available in all other directories.You could do this with
ini_set
.You have to put
ini_set
before thesession_start()
is called. I don't know aboutphpbb
if they give any admin interface to change the session cookie domain value. You should check if phpbb provides this.ini_set('session.cookie_domain','.myWebSite.com');
you could also try