I have been poking around in PHP for OOP and I noticed something… Objects are re-instantiated each time the page is refreshed. The problem is that I want the object to keep certain information in class variables for the whole time that someone is on a website.
- Is there some sort of way to keep an
object alive the whole time that
someone is surfing on the website? - What alternatives are there to my
problem?
It would be really helpful to have example too!
PHP isn’t stateful. Every page load is a one time event. You can persist data with sessions, or by storing information in a database.