tags:

views:

755

answers:

5

I have a C# web-app that I wants to integrate an PHP shopping cart, it is possible? Thanks

+1  A: 

It's not possible unless it is in a database and you write a (de)serialization algorithm that works between both languages. If it's supposed to be a read-only access, I'd make a user with read-only access just for this purpose.

If it is stored on the filesystem I'd consider it insecure to access it.

The Wicked Flea
+1  A: 

Well you need to describe the pieces in more detail really, but it will be non-trivial if it is possible.

How about Response.Redirect to cart.php?inputparams=foo -> do work -> PHP redirect to thankyou.aspx?inputparams=bar

Can you consume the PHP as a service?

Or request the output of the PHP as an HTTPWebRequest?

annakata
+1  A: 

Indeed it depends on the details. Do you want the PHP app to run within your .NET environment? if so I would take a look at Phalanger, but I don't think it will work as you want.

You can also tak a look at PHP on IIS, but that also would not give you a lot of info.

As annakata mentioned I assume you would be better calling/redirecting to/from the PHP script into your ASP.NET website.

And I have a feeling that will not be an easy job to do, so... lucky you ;)

Alexandru Luchian
A: 

There are a few options here. While Java has more options for integration, particularly for sessions, C#/.Net will probably rely upon other products to communicate.

If this were background processing (eg processing of completed orders after checkout), it would probably be simpler. You want to mix web apps however. How and what you want to mix them could (and probably does) make this rather difficult--or at least uncharted waters. PHP runs under Apache and .Net web apps under IIS after all.

You're going to have to go through another technology layer. Others have mentioned databases but that's not a viable or performant solution for session storage on live web apps.

Your best bet is probably memcached, for which there is at least one C# client library. Here's an example of cross-platform serialization using memcached.

beanstalkd may also be worth considering if you have background work processing. It's a distributed work queue process that has several client libraries (eg Ruby, PHP, Perl, Erlang). I couldn't see a C# version but that could probably be done. Refer to the protocol docuentation.

I mention this because you could have PHP write work requests to beanstalkd rather than C# polling or interrogating the PHP session.

cletus
A: 

PHP stores its session in files. A client cookie contains the file name, the php.ini contains the path.

It should be relatively simple to access php session data from dotnet. I'm looking for a library that does this, but if I cannot find one I'll write one myself.

Bar Kemps