If I go print_r($_SESSION) on a drupal page (say mysite.com/ )I only get Session variables set from drupal pages (which are none atm). I can set new ones and they'll show up.



However If I print_r($_SESSION) on a non-drupal page (say mysite.com/somefolder/index.php) on the same domain I get a different (and desired) array:

    [last_url] => /downloads/full.php
    [ip] => ::1
    [address1] => 
    [address2] => Australia
    [zip] => 
    [phone] => 
    [fax] => 
    [dealer] => 
    [referral] => 
    [software] => 
    [searchTerms] => 
    [user_type] => user

I have session_start(); at the beginning of all files.

How does my site seemingly have two $_SESSION arrays? How can I access my $_SESSION vars set on non-drupal scripts within drupal pages?


  • 1
    I think the problem is that you need to tell your external script to use Drupal $_SESSION variable. So you need to use the "drupal_session_start" instead of "session_start". For this, you need to include Drupal bootstrap in your external script. This post looks like it answers your needs: drupal.stackexchange.com/questions/26827/…
    – Matt
    Feb 13, 2014 at 9:28

1 Answer 1


You also need to boostrap drupal before use drupal's sessions (here: Properly bootstrap drupal for standalone PHP file?)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.