Access Drupal functions and session from a PHP script in a subdirectory

Some times in Drupal you may need to create a script in a subdirectory that runs with access to the Drupal functions.
After a few tries and find the inspiration in this site:
http://data.agaric.com/node/2825

This is the answers:

$base_dir = $_SERVER['DOCUMENT_ROOT'];
chdir($base_dir);
require_once "./includes/bootstrap.inc";
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

Enviar un comentario nuevo

El contenido de este campo se mantiene privado y no se mostrará públicamente.
CAPTCHA
Esta prueba es para evitar la entrada de mensajes automatizados. Gracias!
15 + 4 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

Powered by Drupal, an open source content management system

Creative Commons License
Permissions beyond the scope of this license may be available at http://phpia.net/contact