Drupal Session独立脚本的用户标识 [英] Drupal Session User id for independent script

查看:93
本文介绍了Drupal Session独立脚本的用户标识的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个简单的脚本,说a.php。我知道drupal 6创建了一个会话等等。所以在我的a.php我正在尝试print_r($ _ SESSION);但这似乎没有工作。在我的程序中获取登录用户userid的最佳方法是什么?



对不起,我是新来的dr​​upal。谢谢你的时间。

解决方案

Drupal的cron.php是使用库的简单php脚本的完美示例在Drupal的/ includes目录。该文件中的关键行是:

  include_once'./includes/bootstrap.inc'; 
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

如果您将自己的代码包含在内,您的a.php文件将可以访问所有Drupal的上下文和图书馆。


I am creating a simple script say a.php. I know that drupal 6 creates a session etc. So in my a.php I am trying to print_r($_SESSION); but that doesnt seem to work. What is the best way to get the logged in users userid in my program?

Sorry I am new to drupal. Thank you for your time.

解决方案

Drupal's cron.php is a perfect example of a "simple" php script that uses the libraries in Drupal's /includes directory. The key lines in that file are:

include_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

if you include those in your own code, your a.php file will have access to all of Drupal's context and libraries.

这篇关于Drupal Session独立脚本的用户标识的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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