I have a drupal 7 website mydrupal7.com. Authenticated users can complete questionnaires and request reports based on their questionnaires. The questionnaire data is given a unique id which is linked with the user and sent to a custom PHP coded website at reportgenerator.com on the same server. The reportgenerator.com website generates the reports, which are graphically complicated.

The two websites work fine in themselves. It's linking the two that I have the problem with. I would like to use the user authentication of the mydrupal7.com site to say to the reportgenerator.com site "I am an authenticated user, this is a specific questionnaire I have completed, please generate the report." I would prefer the report generation to remain outside of Drupal - ie not a query that relies on data returning to Drupal for rendering, because of the graphically complexity.

I have tried sending session variables (ie this authenticated user, this completed questionnaire) from mydrupal7.com to reportgenerator.com, but they don't persist from the Drupal sessions table to the reportgenerator.com domain. A simple example is:

Code in mydrupal7.com page: $toot = 67; $_SESSION['toot'] = $toot; echo "Toot = " . $_SESSION['toot']; global $user; print_r($user);

Output: Toot = 67 stdClass Object ( [uid] => 1 [name] => admin [pass] => $S$Dl........ [sid] => jgae...... [ssid] => [hostname] => [timestamp] => 1448263956 [cache] => 0 [session] => testuid|i:997;toot|i:67; [roles] => Array ( [2] => authenticated user [3] => administrator ) )

Code in reportgenerator.com page: define( 'DRUPAL_ROOT' , 'R:/htdocs/udrupal'); require DRUPAL_ROOT . '/includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION); global $user; print_r($user);

Subsequent output: stdClass Object ( [uid] => 0 [hostname] => [roles] => Array ( [1] => anonymous user ) [cache] => 0 )

I'm doing something wrong, somewhere ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.