Ok so i have created a class in PHP 5 that uses The Registry Pattern, I will not explain all the details about the registry pattern. I will say that the registry pattern in short is a way to store objects. Below is the code for my ObjectStore class and an example of using it.. For sake of simplicity i am not going to include all of the code, this example builds off code in a previous example you can get that from one of my previous code examples :
So what is the point of this class? Currently nothing it was done to show an example how you could use the registry pattern and store your objects accross pages without having to bulk up the session object. Is this code ready for production use? NO WAY! You should add some sort of encryption to this class. I would do a 2-way encryption algorithm where only you know the key. When you store the objects on disk you store the encrypted value. When reading you decrypt. This could also be expanded to hold objects that do not persist accross pages as well. Maybe something like $objstore->set('employee', $e, TRUE/FALSE) This would allow you to specify if the object should be serialized and saved etc..