I'm creating a new module.
In a part of my newmodule.module I have a array that I have to sent to a file php.

For this reason I do in newmodule.module:
$_SESSION['array']=$b;

$b is the array generated for my module.

What is the code in file php for capture $_SESSION['array']?

I do a simple file php for view the result of the recovery of $_SESSION['array'] but it is empty.
The code of file php is:

session_start();
$b=$_SESSION['array'];
print_r($b);

This code works perfectly for 'send' $_SESSION from a file php to other file php, but in this case don't works.

Any solution or idea that I must do to recover $_SESSION ?

Very Thanks

Comments

markus_petrux’s picture

Drupal uses its own session handlers and stores session data in database. You would have to do something like this:

// Include Drupal stuff
require_once './includes/bootstrap.inc';
// Initialize the Drupal database and session layers.
drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);

// Now, $_SESSION contains data retrieved from the Drupal session table.
$b=$_SESSION['array'];
print_r($b);

Doubt is the beginning, not the end of wisdom.

Montt’s picture

I copy your code and I add:
echo("I'm solving problem with $_SESSION");

My problem now is this:
- The lines: require_once './includes/bootstrap.inc' and drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION); provokes screen in target.
If I elimate this line I view: I'm solving problem with $_SESSION

I don't understand where is the problem, I use require_once other occasions and don`t cause problems.