简体   繁体   English

如何在Drupal的自定义php文件中设置会话变量?

[英]How do I set session variables in a custom php file in Drupal?

In a subpage on my drupal site I have a form. 在我的drupal网站的一个子页面中,我有一个表格。 I'd like the form to post to a simple process.php file, that takes the form data and then sets a $_SESSION variable and returns the user to the original page. 我希望将表单发布到一个简单的process.php文件中,该文件将获取表单数据,然后设置$ _SESSION变量并将用户返回到原始页面。

Currently the process.php file is not seeing the $_SESSION vars set in standard drupal pages and viceversa, drupal pages don't see the $_SESSION vars set in the process.php file, they act as if they are on completely different sites. 当前,process.php文件在标准drupal页面中没有看到$ _SESSION变量,反之亦然,drupal页面在process.php文件中没有看到$ _SESSION变量,它们的作用就像在完全不同的站点上一样。 What am i missing? 我想念什么?

From my research it looks like the only way to set session variables and run your own php code is to create a module. 从我的研究看来,设置会话变量和运行自己的php代码的唯一方法是创建一个模块。

I've looked at the Drupal.org tutorial here: https://www.drupal.org/developing/modules and this one here: http://www.wdtutorials.com/2012/04/29/drupal-7-how-create-module-part-1 我在这里查看了Drupal.org教程: https : //www.drupal.org/developing/modules和这里的一个: http : //www.wdtutorials.com/2012/04/29/drupal-7-如何创建模块部分-1

Lastly, I'd also recommend looking at existing modules and learning from those as well. 最后,我还建议您查看现有模块并从中学习。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM