Does session variables work when using background process?
I have two php scripts - index.php:
session_start();
$_SESSION['test'] = 'test';
$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run("C:/xampp/php/php-cgi.exe -f C:/xampp/htdocs/sand_box/background.php".session_id(), 0, false);
/*
continue the program
*/
and the background.php:
session_id($argv[1]);
session_start();
sleep(5);
$test = $argvs[1];
$myFile = "myFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, $test);
fclose($fh);
The background process creates the myFile.txt however the session variable doesn't work. I did some other tests and it doesn't work in any case. Anyone knows why?
Is it a limitation of using a background process?
I edited the code, my problem now is that I can't pass any variable as arguments. $argv is always empty.
I finally solved it, register_argc_argv must be enabled on php.ini!