Re: Link to .php page with session

From: Date: Tue, 16 Jun 2009 14:28:43 +0000
Subject: Re: Link to .php page with session
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-294086@lists.php.net to get a copy of this message
On Tue, Jun 16, 2009 at 08:23, Stuart<stuttle@gmail.com> wrote: > > I may have interpreted your problem incorrectly, but I think your > problem is due to the session data not being saved until the script > has finished running, including the system call. To get around this > you can save and close the session before calling system using the > session_write_close [1] function. Note that after calling that you > won't be able to make any other changes to the session data in that > request. Stuart (<plug>who I saw yesterday is listed as a Twitter API developer in the official docs, by the way ;-P </plug>) hit the nail right on the head there, Santel. Until the system() function receives a return response from the spawned application, it'll hold up the rest of the page execution. There are, among others, two ways you could easily handle this: 1.) Write a wrapper shellscript, for which I'll give a simple example below. 2.) Use the proc_open()[1] or popen()[2] functions in PHP. To use a wrapper script is simple, and here's one way of doing it: ======== <?php // yourfile.php // Your existing code goes here, replacing the system() call with: system("./convert.sh file.wmv"); // .... and then continue with your code. ?> ==== #!/bin/bash # convert.sh # Remember to chmod this to 0755 or similar, allowing it to execute. nohup /usr/bin/ffmpeg -re -i $1 -f flv -an -sameq - >> /dev/null 2>&1 & # End of shellscript. ======== This requires only that you pass the name of the file to be encoded, and then sends all of the output from ffmpeg to /dev/null (including STDERR) and detaches the process from the shell (spawning a poor-man's daemon ;-P). Ref: ^1: http://php.net/proc_open ^2: http://php.net/popen -- </Daniel P. Brown> daniel.brown@parasane.net || danbrown@php.net http://www.parasane.net/ || http://www.pilotpig.net/ 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW10000

« previous php.general (#294086) next »