问题描述
我正在拔头发试图弄清楚这一点.在 Drupal 目录之外时,我无法让 Bootstrap 正常工作.如果我在 Drupal 目录中运行此代码,它可以正常工作,但上一级不起作用.
I'm pulling my hair out trying to figure this one out. I can't get the Bootstrap to work properly when outside of the Drupal dir. It works fine if I run this code in the Drupal dir, but up one level doesn't work.
我的 Drupal 路径是/public_html/drupal/.我正在运行的脚本在/public_html 中.
My Drupal path is /public_html/drupal/. The script I'm running is in /public_html.
$user 没有返回登录的用户.我已经确定这不是跨域问题(即 www.domain.com 与 domain.com).
$user is not returning the logged in user. I've made sure it's not a cross-domain issue (i.e. www.domain.com vs. domain.com).
chdir('/path/to/drupal');
include_once('./includes/bootstrap.inc');
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
global $user;
if ($user->uid) {
print "Logged in";
} else {
print "Logged out";
}
推荐答案
如果 Drupal 在您的单独脚本中未识别用户,则很有可能它没有收到正确的会话 cookie.您应该检查正常 Drupal 安装设置的 cookie,看看它们是否也发送到您的脚本.如果没有,请检查 Drupals settings.php 中的 $cookie_domain 变量 - 通常它已被注释掉,但您可能需要在您的情况下明确设置它.
If the user is not recognized by Drupal in your separate script, chances are high that it does not receive the proper session cookie. You should check the cookies set by your normal Drupal install and see if they get send to your script as well. If not, check the $cookie_domain variable in your Drupals settings.php - ususally it is commented out, but you might need to set it explicitly in your case.
这篇关于Drupal - 使用 boostrap 在 Drupal 之外检查登录用户不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)