in reply to Re: Using Sessions between perl and php.
in thread Using Sessions between perl and php.

Ok, I'll have to try and explain things better. I know how Apache::Session works and I know that it uses Storable to serialize data types to store in the database.

What I am trying to say, have you thought that using Apache::Session is maybe the best possible solution to your problem?

Looking at your documentation (and pointed out by Screamer) you can't use arbitrary data structures. I'm not sure where this limitation comes from but it means that you don't need the flexibility gained by using Storable.

From your PHP code, it seems that you have to exec a perl script every time you read or write a variable. This seems very inefficient to me.

I don't think it would be to hard, I had a quick look at the source for Apache::Session::MySQL and you can probably work from this and it's subclasses (reusing the one for locking etc) to create an Apache::Session module that doesn't use Storable.

gav^

  • Comment on Re: Re: Using Sessions between perl and php.

Replies are listed 'Best First'.
Re: Re: Re: Using Sessions between perl and php.
by jryan (Vicar) on Jan 21, 2002 at 06:23 UTC

    You are completely missing the whole point of this: IT IS NOT PURE PERL. Its not. Really.

    We used Apache::Session because it worked. It works well. PHP sessions also worked well for us. These two systems were already in place.

    Now, we needed them to talk to each other. PHP provides a method to the default session handling functions. Rather than screw with Apache::Session::MySQL (of which we already had a bitch of a time getting installed), we decided the best route to take was to take advantage of PHP's overridable functions. So we did. The key part here (which you seem to disagree with, probably because you haven't researched this very deeply), is that we needed a way to take the php-serialized data and convert it to perl-serialized data.

    Thats where the perl script that the php script calls comes in. A php-serialized associative array is passed as a command line argument. A perl module deserializes this structure into a hash. The hash is then serialized with Storable. This string is then updated into the sessions database. A reverse process is done when the session data is extracted. Perl, on the other hand, simply grabs the data using the normal Apache::Session::MySQL.

    Yes, its a bit odd, but then it isn't a very normal task. Using our method, pure perl scripts can still take advantage of the full power of Storable, AND we didn't have to have a hacked version of Apache::Session::MySQL in order to get it to work. I fail to see how your method is any easier ours...