Accessing PHP variables with Perl

K

Kubaton Lover

I have a site which is primarily PHP and I'm setting a bunch of PHP
environment variables with statements like:
$HTTP_SESSION_VARS['valid_user'] = $userid;

Is there a way for my Perl scripts to access those session variables? I've
never done that before with Perl.

Thanks.
 
J

Jim Toth

I have a site which is primarily PHP and I'm setting a bunch of PHP
environment variables with statements like:
$HTTP_SESSION_VARS['valid_user'] = $userid;

Is there a way for my Perl scripts to access those session variables? I've
never done that before with Perl.

Environmental variables are in the %ENV hash.

perl -le 'print $ENV{"SHELL"}'

If the session variables are indeed environmental
variables, they should be accessible that way.
 
K

Kubaton Lover

Jim Toth said:
I have a site which is primarily PHP and I'm setting a bunch of PHP
environment variables with statements like:
$HTTP_SESSION_VARS['valid_user'] = $userid;

Is there a way for my Perl scripts to access those session variables? I've
never done that before with Perl.

Environmental variables are in the %ENV hash.

perl -le 'print $ENV{"SHELL"}'

If the session variables are indeed environmental
variables, they should be accessible that way.

I thought so, too, but when I run the following code, none of those
variables show up even though other PHP scripts see the variables without a
problem.

Perl script:
foreach $env_var (keys %ENV) {
print "$env_var = <font color=blue>$ENV{$env_var}</font><br>";
}
 
L

Leif K-Brooks

Jim said:
Environmental variables are in the %ENV hash.

perl -le 'print $ENV{"SHELL"}'

If the session variables are indeed environmental
variables, they should be accessible that way.

No, PHP stores session variables in temp files (one for each session).
You would need to use a custom session handler of some sort to share them.
 
J

James Willmore

I have a site which is primarily PHP and I'm setting a bunch of PHP
environment variables with statements like:
$HTTP_SESSION_VARS['valid_user'] = $userid;

Is there a way for my Perl scripts to access those session
variables? I've never done that before with Perl.


Try using the PHP::Session module
http://search.cpan.org/~miyagawa/PHP-Session-0.22/lib/PHP/Session.pm

HTH

--
Jim

Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.

a fortune quote ...
Death is God's way of telling you not to be such a wise guy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,298
Messages
2,571,542
Members
48,283
Latest member
RitaVui655

Latest Threads

Top