在Drupal 6中如何存储和检索自定义会话变量? [英] How does one store and retrieve custom session variables in Drupal 6?

查看:111
本文介绍了在Drupal 6中如何存储和检索自定义会话变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Drupal使用一个自定义会话处理程序来更改熟悉的...:

Drupal employs a custom session handler that changes the familiar...:

$ _ SESSION ['foo'] ='bar'

echo $ _SESSION ['foo'];

...行为。 foo的上述会话变量不会在页面之间保留。

...behavior. The above session variable of "foo" would not persist from page to page.

Drupal.com上的许多注释和论坛条目引发了Drupal使用自定义会话处理程序的问题出于性能原因和服务器集群支持。但是,我没有找到具体的例子来回答这个问题 - 需要在Drupal的页面上管理你自己的会话变量,不想诉诸于cookies,这样做...

Many comments and forum entries at Drupal.com raise the issue that Drupal uses a custom session handler for performance reasons and server clustering support. However, I'm failing to find specific examples answering the question - "Need to manage your own session variables across pages in Drupal and don't want to resort to cookies? Here's how you do it..."

有没有人有这方面的经验?我的使用不会在外部Drupal页面中,而在模板页面中。这是一个匿名用户,不是登录的用户。 $ _SESSION的行为是在这种情况下预期的。

Does anyone have experience with this? My usage would NOT be within external Drupal pages but within template pages themselves. This is for an anonymous user, not a logged in one. $_SESSION behavior is as expected in that case.

推荐答案

好的,这里是答案 - $ _SESSION适用于经过身份验证的用户以及匿名用户如预期 - 如果没有其他问题!

Ok, here's the answer - $_SESSION works for authenticated users as well as anonymous users as expected - if there are no other problems!

我发现我有以下问题;我的Drupal用户表(或在我的情况下为drupal_users)缺少UID为零(0)的用户。

I discovered that I had the following problem; my Drupal "users" table (or in my case "drupal_users") was missing a user with a UID of zero ("0").

Drupal使用UID 0通过其自定义会话处理程序在数据库中管理会话。如果表中不存在该用户(应该在默认情况下安装),则Drupal无法将会话信息附加到匿名用户。

Drupal uses UID 0 to manage sessions in a database via its custom session handler. If that user doesn't exist in the table (it should be there by default installation), then Drupal cannot attach session information to the anonymous user.

这篇关于在Drupal 6中如何存储和检索自定义会话变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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