everisk Posted May 26, 2009 Share Posted May 26, 2009 Hello, Now I'm using iframe to launch the script in background and meta redirect to redirect page. However, the problem is it seems like the system has to wait for background_script to completely loaded before redirecting. Is there any other way to do this? Any help is greatly appreciated. Thanks! echo '<iframe src="background_script.php" width="0" height="0"></iframe>'; echo '<meta http-equiv="Refresh" content="0; url=../context/redirect-to.php">'; Quote Link to comment https://forums.phpfreaks.com/topic/159667-launch-file-in-background-and-then-redirect-page/ Share on other sites More sharing options...
JonnoTheDev Posted May 26, 2009 Share Posted May 26, 2009 By forking it as a background process. exec("php /path/to/script.php > /dev/null &"); header("Location:file.php"); exit(); Quote Link to comment https://forums.phpfreaks.com/topic/159667-launch-file-in-background-and-then-redirect-page/#findComment-842141 Share on other sites More sharing options...
everisk Posted May 26, 2009 Author Share Posted May 26, 2009 Thanks! This works on all OS? I did some search and it looks like it might not work on Windows? I have never used exec() before and I need the script to work on both Windows and Unix. Quote Link to comment https://forums.phpfreaks.com/topic/159667-launch-file-in-background-and-then-redirect-page/#findComment-842152 Share on other sites More sharing options...
JonnoTheDev Posted May 26, 2009 Share Posted May 26, 2009 It will work, just checkout the php manual pages for exec Quote Link to comment https://forums.phpfreaks.com/topic/159667-launch-file-in-background-and-then-redirect-page/#findComment-842162 Share on other sites More sharing options...
everisk Posted May 27, 2009 Author Share Posted May 27, 2009 I have done a bit more research and found that exec() might not work on some windows environment I tried with cURL and get it working to a certain extent, but then the problem is that my script checks session id for security and the page that gets called by cURL does NOT retain the same session id as the parent script. Is there any way to force cURL to use the same session id as the parent script? I tried passing the session id and set it in the target script before checking it, but the script just halts. Quote Link to comment https://forums.phpfreaks.com/topic/159667-launch-file-in-background-and-then-redirect-page/#findComment-843263 Share on other sites More sharing options...
JonnoTheDev Posted May 27, 2009 Share Posted May 27, 2009 Impossible as that would be an example of session hijacking Quote Link to comment https://forums.phpfreaks.com/topic/159667-launch-file-in-background-and-then-redirect-page/#findComment-843265 Share on other sites More sharing options...
everisk Posted May 28, 2009 Author Share Posted May 28, 2009 ah ok ..thanks! neil.johnson Quote Link to comment https://forums.phpfreaks.com/topic/159667-launch-file-in-background-and-then-redirect-page/#findComment-843895 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.