The Problem:
I want to take some data that is generated within a PHP script (a simple string 'dirTemp' which holds an absolute directory path) and make it available to a separate Perl script.
I don't want to hard-code any paths in either of the scripts because (a) most data is generated on the fly, and (b) I want to make installation of these scripts as simple as possible (i.e. minimal configuration).
My development machine is WAMP and remote hosting server is LAMP.
Considered Solutions:
1. Setting 'dirTemp' in a Cookie
This works great, but with one major drawback - security! Apart from giving potential hackers an insight into my directory structure, cookies can be very easily spoofed so would cause some havoc within the target perl script.
2. Storing 'dirTemp' in the Session, then using "PHP::Session" Perl module to read it
This seems like a more secure solution, but the Perl scripts still needs to know the session 'save_path', so we get back to square one - needing to send a directory path to Perl! The system I'm developing also uses custom Session handlers (D and PHP::Session currently only supports file-based sessions.
3. Setting an environment variable in PHP so Perl can read it
On my windows machine, PHP generates a "tmp" environment variable, but Perl doesn't. The languages don't seem to have any directory environment variable in common. If they did, this would be great as I could create a file based on a unique ID in that "tmp" directory, then simply pass the ID to perl via a cookie (this would be safe).
So I've tried using "putenv()" and "apache_setenv()" to set the environment variable in PHP, but they don't become available to the Perl script.
So, none of the solutions I've come up with so far cut the mustard. Of the three I think the environment variables would be the simplest and neatest way around it, and possibly the Apache "SetEnv" directive may help, but before I delve into Apache (with which I'm very clumsy) I'd like to exhaust other solutions.
Hopefully someone out there can point out what's missing and solve this little conundrum in one fell swoop!