Persistant session objects performances
Posted: Fri Jul 05, 2002 2:00 am
Hello everyone!
Today I was thinking about a cart for an e-commerce application and I asked myself what would be the best way to do it in my application.
I've had previou experience with e-commerce products written for IIS in ASP and I still think that ASP has a big advantage in this kind of applications. I'm explaining why and I would like to know if there's a way to do the same with PHP that I am not aware of.
In ASP you can create a new object and save it as a Session variable. From now on, I can stay assured that by simply checking if the variable exists I know if there's a cart for the current user.
Whenever I feel the need to do so, I can dump the cart to a DB backend for later use and reload it if I loose the session.
This way of doing a cart has real good performances with IIS and I think it's due to the way IIS and ASP have been bounf together.
Months ago I tried doing something similar with PHP storing objects as session variables, but the performance was horrible. I think it is because of the way PHP handles session stuff. For every page you load, PHP is reloading the content of the session variables from a file and if you've got many objects or a very big one, it sits down.
I have already tried using a different approach by saving the cart in the DB and only using the session id along with the userid to retrieve the cart in every page. It's much faster but it's a waste of resources in my opinion.
The main problem seems to be that once I create an object I cannot make it persistant until the time I stop Apache. I don't know if there's a workaround or if this is just a limit of PHP.
I hope someone out there can snlighten me.
Today I was thinking about a cart for an e-commerce application and I asked myself what would be the best way to do it in my application.
I've had previou experience with e-commerce products written for IIS in ASP and I still think that ASP has a big advantage in this kind of applications. I'm explaining why and I would like to know if there's a way to do the same with PHP that I am not aware of.
In ASP you can create a new object and save it as a Session variable. From now on, I can stay assured that by simply checking if the variable exists I know if there's a cart for the current user.
Whenever I feel the need to do so, I can dump the cart to a DB backend for later use and reload it if I loose the session.
This way of doing a cart has real good performances with IIS and I think it's due to the way IIS and ASP have been bounf together.
Months ago I tried doing something similar with PHP storing objects as session variables, but the performance was horrible. I think it is because of the way PHP handles session stuff. For every page you load, PHP is reloading the content of the session variables from a file and if you've got many objects or a very big one, it sits down.
I have already tried using a different approach by saving the cart in the DB and only using the session id along with the userid to retrieve the cart in every page. It's much faster but it's a waste of resources in my opinion.
The main problem seems to be that once I create an object I cannot make it persistant until the time I stop Apache. I don't know if there's a workaround or if this is just a limit of PHP.
I hope someone out there can snlighten me.