[PHP] php script calling another one (on different machine), session variables
I have two Windows machines. machine A has apache/mysql/php (main host) machine B has apache/media server (secondary host for high bandwidth media such as video) I have admin tools (written in PHP and using sesson variables) on A which allows for updating of the database with pictures and such. The admin tools also allows you to delete records. When the user deletes a record using the admin tools on machine A, I also want to delete some media files on machine B. At this point, I figured that I should have my admin tools call a PHP script on machine B to delete files from the B's filesystem. I did a search online and it seems that I should use a header() call to call the PHP script on machine B. But what if I want to RETURN the user to the admin tools? Can I send another header() from machine B's script? What will happen to the session variables? How can I hold onto the session variables while moving between web servers? -- -James -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php script calling another one (on different machine), session variables
I just thought of something... Will this work... (machine A) User hits submit in the Admin Tools to delete a record. (machine A) I send POST variables to a database php script in a NEW WINDOW...at the end of the script...it uses a header() to call the PHP script on machine B...to delete files from that machine. (machine B) after the php script runs and deletes the media files, it displays a SUCCESS...please close window which appears in the new window. The user still has the admin tools, with it's session variables, in the parent window. -James At 2:43 PM -0400 8/1/05, James wrote: I have two Windows machines. machine A has apache/mysql/php (main host) machine B has apache/media server (secondary host for high bandwidth media such as video) I have admin tools (written in PHP and using sesson variables) on A which allows for updating of the database with pictures and such. The admin tools also allows you to delete records. When the user deletes a record using the admin tools on machine A, I also want to delete some media files on machine B. At this point, I figured that I should have my admin tools call a PHP script on machine B to delete files from the B's filesystem. I did a search online and it seems that I should use a header() call to call the PHP script on machine B. But what if I want to RETURN the user to the admin tools? Can I send another header() from machine B's script? What will happen to the session variables? How can I hold onto the session variables while moving between web servers? -- -James -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- -James -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php script calling another one (on different machine), session variables
On 8/1/05, James [EMAIL PROTECTED] wrote: I have two Windows machines. machine A has apache/mysql/php (main host) machine B has apache/media server (secondary host for high bandwidth media such as video) I have admin tools (written in PHP and using sesson variables) on A which allows for updating of the database with pictures and such. The admin tools also allows you to delete records. When the user deletes a record using the admin tools on machine A, I also want to delete some media files on machine B. At this point, I figured that I should have my admin tools call a PHP script on machine B to delete files from the B's filesystem. I did a search online and it seems that I should use a header() call to call the PHP script on machine B. Um.. No. You use header when you want to pass additional headers to the browser, that is downloading your content. An example of this would be when you want to serve up a PNG image, instead of html, you would use header(Content-type: image/png) You can use a header to redirect a user to scripts on another system. To do this you would pass a location header header(Location: serverb.com/whatever) If you want to call a script on machine B, then you can either simply use file handling functions eg: fopen(http://machineb/page.php;), or www.php.net/curl But what if I want to RETURN the user to the admin tools? Can I send another header() from machine B's script? What will happen to the session variables? How can I hold onto the session variables while moving between web servers? Do the two machines share a common domain name? are your machines for example boxa.commondomain.com and boxb.commondomain.com if so then you can have the cookies(which hold the session tracking number) operate at the commondomain.com level. All you have to do then is configure one machine to get session files from the other. Otherwise you can use session.use_trans_sid and add the SID to the url when you header(Location) In windows you could do this by setting up a share containing the session files, and modding your php.ini file to reflect that the session info is stored in this file. If you don't have admin access to your boxes, then you could write a session handler on one of the systems to dl the necessary sesssion info on demand. For more info see Having that said, it seems to be a fairly common requirement - so there may be a cleaner solution to the one I have outlined here. I've just never needed it - so therefore I've never come across it. -- -James -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php script calling another one (on different machine), session variables
Rory Browne wrote: On 8/1/05, James [EMAIL PROTECTED] wrote: ... Do the two machines share a common domain name? are your machines for example boxa.commondomain.com and boxb.commondomain.com if so then you can have the cookies(which hold the session tracking number) operate at the commondomain.com level. All you have to do then is configure one machine to get session files from the other. Otherwise you can use session.use_trans_sid and add the SID to the url when you header(Location) In windows you could do this by setting up a share containing the session files, and modding your php.ini file to reflect that the session info is stored in this file. If you don't have admin access to your boxes, then you could write a session handler on one of the systems to dl the necessary sesssion info on demand. For more info see purely out of interest, see what? :-) Having that said, it seems to be a fairly common requirement - so there may be a cleaner solution to the one I have outlined here. I've just never needed it - so therefore I've never come across it. -- -James -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php script calling another one (on different machine), session variables
On 8/1/05, Jochem Maas [EMAIL PROTECTED] wrote: Rory Browne wrote: On 8/1/05, James [EMAIL PROTECTED] wrote: ... Do the two machines share a common domain name? are your machines for example boxa.commondomain.com and boxb.commondomain.com if so then you can have the cookies(which hold the session tracking number) operate at the commondomain.com level. All you have to do then is configure one machine to get session files from the other. Otherwise you can use session.use_trans_sid and add the SID to the url when you header(Location) In windows you could do this by setting up a share containing the session files, and modding your php.ini file to reflect that the session info is stored in this file. If you don't have admin access to your boxes, then you could write a session handler on one of the systems to dl the necessary sesssion info on demand. For more info see purely out of interest, see what? :-) Sorry - but I thought someone of your experience Jochem would know :) See: http://www.php.net/manual/en/function.session-set-save-handler.php Having that said, it seems to be a fairly common requirement - so there may be a cleaner solution to the one I have outlined here. I've just never needed it - so therefore I've never come across it. -- -James -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php script calling another one (on different machine), session variables
Rory Browne wrote: ... If you don't have admin access to your boxes, then you could write a session handler on one of the systems to dl the necessary sesssion info on demand. For more info see purely out of interest, see what? :-) Sorry - but I thought someone of your experience Jochem would know :) experience? me? only the bad kind ;-) See: http://www.php.net/manual/en/function.session-set-save-handler.php ah, righty ho. that does look familiar - I just assumed that you were pointing to some resource/article elsewhere than php.net - didn't cross my mind that you might just have been pointing to OP to the most natural place to start reading about sessions (or anything php for that matter) - which is why I asked, you never you when you can learn something new! :-) that said I have always been satisfied with the default session handler (and given that (nearly) all my work is published either on my 'own' server (not really mine but I have full control and there are no 'anon' 3rd party running stuff) or on dedicated servers belonging to clients I don't have to worry about all the potential security risks involved with (badly setup?) shared hosting environments. for that reason (and lack of time) I have never really dived deep into to the possibilities of custom session handlers (I have used some 3rd party code once that used a mysql DB to store the session data which was a quite simple affair - such a setup would allow sharing of sessions accross various boxes asumming a shared base domain) rgds, jochem -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php script calling another one (on different machine), session variables
Thanks Rory: I tried using fopen() and CURL and they both worked like a charm! No need to juggle redirects and session variables. -James At 9:21 PM +0200 8/1/05, Rory Browne wrote: On 8/1/05, Jochem Maas [EMAIL PROTECTED] wrote: Rory Browne wrote: On 8/1/05, James [EMAIL PROTECTED] wrote: ... Do the two machines share a common domain name? are your machines for example boxa.commondomain.com and boxb.commondomain.com if so then you can have the cookies(which hold the session tracking number) operate at the commondomain.com level. All you have to do then is configure one machine to get session files from the other. Otherwise you can use session.use_trans_sid and add the SID to the url when you header(Location) In windows you could do this by setting up a share containing the session files, and modding your php.ini file to reflect that the session info is stored in this file. If you don't have admin access to your boxes, then you could write a session handler on one of the systems to dl the necessary sesssion info on demand. For more info see purely out of interest, see what? :-) Sorry - but I thought someone of your experience Jochem would know :) See: http://www.php.net/manual/en/function.session-set-save-handler.php Having that said, it seems to be a fairly common requirement - so there may be a cleaner solution to the one I have outlined here. I've just never needed it - so therefore I've never come across it. -- -James -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- -James -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php