session - Passing variable between php web page and a background script -


i trying run php script in background on windows.

im looking way pass variable between them. thats im trying accomplish:

php page:

  session_start();   $_session['abc'] = 1 ;          $cmd = "c:\wamp\bin\php\php5.5.12\php -f c:\wamp\www\finalproject\newemptyphp.php" ;     pclose(popen("start /b ".$cmd, 'r'));   while ( $_session['abc'] == 1)   {       sleep(1) ;    }   echo 'done'; 

background script:

session_start(); $_session['abc'] = 0 ;  

im open suggestions.

you should execute passing var argument on console call:

    session_start();     $_session['abc'] = 1 ;     $cmd = "c:\wamp\bin\php\php5.5.12\php -f c:\wamp\www\finalproject\newemptyphp.php " . $_session['abc'] ;       /** ... */ 

after able argument newemptyphp.php using $argv var (http://php.net/manual/en/reserved.variables.argv.php)

i think never session updated in way because: 1) php not listening external changes in $_session during execution. if possible, difficult maintain , debug. 2) script in console not using sessions session accessible client opened (see http://www.w3schools.com/php/php_sessions.asp) but... why need call php script php using popen? slow. recommend build feature need use newemptyphp.php inside application.


Comments