Drupal 6 将消息设置为不同的引导程序
我正在尝试使用上面的代码来设置消息并重定向到不同的位置,如下所示 我正在重定向
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我将运行
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.您确实不需要花这些功夫来重定向 Drupal 页面,自定义模块中像这样简单的事情就可以做到:
不过,我不完全确定您为什么要这样做,从您的消息中我收集到了这一点响应表单提交?如果是这样,您最好在表单的提交处理程序中设置
$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:
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.