简体   繁体   中英

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

In a subpage on my drupal site I have a form. 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.

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. 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.

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

Lastly, I'd also recommend looking at existing modules and learning from those as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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