Alex Rivera | Logout

Is there a way to share object between php pages?

Asked 2009-05-25T21:33:06.667
12

I am new to php, but in other web technologies, you can share objects between page instances. For example, in java jsp pages you easily have on class that exist as static class for the whole server instance. How to do this in php?

I am not refering to sessions variables (at least I don't think so). This is more for the purpose of resource pooling (perhaps a socket to share, or database connections etc). So a whole class needs to be shared between subsequent loads, not just some primitive variables that I can store in the session.

I have also looked into doing php singleton classes but I believe that class is only shared within the same page and not across pages.

To make things even more clear, I'm looking for something that can help me share, say, a socket connected to a server for a connectSocket.php page such that all users who loads that page uses the same socket and does not open a new one.

Edit
Report

1 Answer

0

An other horroble solution may be to load the data of the object to any $_SESSION variable and then user it back into the object of the other page. In fact, this is the solution I'm going to follow in my project, until I get some better one.

Regards!

answered 2010-04-14T16:33:02.937

Your Answer