Alec Smart
Alec Smart

Reputation: 95900

Drupal Session User id for independent script

I am creating a simple script say a.php. I know that drupal 6 creates a session etc. So in my a.php I am trying to print_r($_SESSION); but that doesnt seem to work. What is the best way to get the logged in users userid in my program?

Sorry I am new to drupal. Thank you for your time.

Upvotes: 2

Views: 1880

Answers (1)

Eaton
Eaton

Reputation: 7415

Drupal's cron.php is a perfect example of a "simple" php script that uses the libraries in Drupal's /includes directory. The key lines in that file are:

include_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

if you include those in your own code, your a.php file will have access to all of Drupal's context and libraries.

Upvotes: 8

Related Questions