Drupal Session User id for independent script(独立脚本的 Drupal 会话用户 ID)
问题描述
我正在创建一个简单的脚本,比如 a.php.我知道drupal 6 创建了一个会话等等.所以在我的a.php 中我试图print_r($_SESSION);但这似乎不起作用.在我的程序中获取登录用户 userid 的最佳方法是什么?
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?
抱歉,我是 Drupal 的新手.感谢您抽出宝贵时间.
Sorry I am new to drupal. Thank you for your time.
推荐答案
Drupal 的 cron.php 是使用 Drupal 的/includes 目录中的库的简单"php 脚本的完美示例.该文件中的关键行是:
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);
如果您将这些包含在您自己的代码中,您的 a.php 文件将可以访问所有 Drupal 的上下文和库.
if you include those in your own code, your a.php file will have access to all of Drupal's context and libraries.
这篇关于独立脚本的 Drupal 会话用户 ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:独立脚本的 Drupal 会话用户 ID


基础教程推荐
- 在 CakePHP 2.0 中使用 Html Helper 时未定义的变量 2021-01-01
- HTTP 与 FTP 上传 2021-01-01
- 在 yii2 中迁移时出现异常“找不到驱动程序" 2022-01-01
- 找不到类“AppHttpControllersDB",我也无法使用新模型 2022-01-01
- PHP 守护进程/worker 环境 2022-01-01
- phpmyadmin 错误“#1062 - 密钥 1 的重复条目‘1’" 2022-01-01
- Doctrine 2 - 在多对多关系中记录更改 2022-01-01
- 使用 PDO 转义列名 2021-01-01
- 如何在 Symfony 和 Doctrine 中实现多对多和一对多? 2022-01-01
- 如何在 XAMPP 上启用 mysqli? 2021-01-01