Drupal 6 将消息设置为不同的引导程序

发布于 2024-12-10 07:57:01 字数 827 浏览 0 评论 0原文

我正在尝试使用上面的代码来设置消息并重定向到不同的位置,如下所示 我正在重定向

example.com/somewere/index.php

example.com

我的问题是当我到达 example.com 时 drupal 不会保留会话, 并且该消息未显示。

任何想法将不胜感激。

chdir('../'); 
require_once './includes/bootstrap.inc';
require_once './includes/common.inc';
require_once './includes/module.inc';

$url = "http://".$_SERVER['SERVER_NAME'];

drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
drupal_set_message(t('Your message has been sent'), 'status', TRUE);
drupal_goto($url);

我正在采取一个表单和页面的一些其他元素,并将其放在drupal之外的启用会话的引导程序中。

在 example.com/somewere/ 我的消息就在那里,

但是在 example.com/ 上 消息

我没有收到服务器为我打开不同会话的 难道是因为我在 example.com/somewere/ 中使用了不同的 htaccess 文件,

我知道消息是基于会话的 有没有办法绕过这个问题,因为在同一个域和同一个 drupal 上只是不同的访问位置?

I'm trying the above code to set a message and redirect to a different location like this
and i'm redirecting from

example.com/somewere/index.php

to

example.com

My problem is when i get to example.com drupal doesen't keep the session,
and the message is not shown.

Any idea will be much appreciated.

chdir('../'); 
require_once './includes/bootstrap.inc';
require_once './includes/common.inc';
require_once './includes/module.inc';

$url = "http://".$_SERVER['SERVER_NAME'];

drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
drupal_set_message(t('Your message has been sent'), 'status', TRUE);
drupal_goto($url);

i'm taking a form and some other elements of the page and putting it outside drupal in a bootstrap that has session enable.

in
example.com/somewere/
my message is there

but on example.com/
i dont get the message

the server open me a diffrent session
can it be because i use a diffrent htaccess file in example.com/somewere/

i know messages are session based
is there a way to bypass the problem because there on the same domain and same drupal just different access position ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

神仙妹妹 2024-12-17 07:57:01

我将运行 session_get_cookie_params 来查看路径是否只是 /。可能是 PHP 将会话 cookie 的路径设置为 /somewhere,因此您安装的 Drupal 安装之后就没有会话 cookie。

I would run session_get_cookie_params to see whether the path is just /. It might be that PHP sets the path to /somewhere for the session cookie and so the Drupal install in your install doesnt have a session cookie after that.

时光磨忆 2024-12-17 07:57:01

您确实不需要花这些功夫来重定向 Drupal 页面,自定义模块中像这样简单的事情就可以做到:

function mymodule_init() {
  if ($_GET['q'] == 'index.php') {
    $url = "http://".$_SERVER['SERVER_NAME'];
    drupal_set_message(t('Your message has been sent'), 'status', TRUE);
    drupal_goto($url);
  }
}

不过,我不完全确定您为什么要这样做,从您的消息中我收集到了这一点响应表单提交?如果是这样,您最好在表单的提交处理程序中设置 $form_state['redirect'] = $url

You really don't need to go to these lengths to redirect a Drupal page, something as simple as this in a custom module will do it:

function mymodule_init() {
  if ($_GET['q'] == 'index.php') {
    $url = "http://".$_SERVER['SERVER_NAME'];
    drupal_set_message(t('Your message has been sent'), 'status', TRUE);
    drupal_goto($url);
  }
}

I'm not entirely sure why you would do this is though, from your message I gather this in response to a form submission? If so you'd be better off setting $form_state['redirect'] = $url in a submission handler for the form.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文