I have instantiated a class in my index.php file. But then I use jQuery Ajax to call some PHP files, but they can’t use my object that I created in the index.php file.
How can I make it work? Because I don´t want to create new objects, because the one I created holds all the property values I want to use.
Use the session to save the object for the next page load.
Then in the next page that loads from AJAX
By using the PHP sessions you can save data across many pages for a certain user. For example, maybe each user has a shopping cart object that contains a list of items they want to buy. Since you are storing that data in THAT USERS session only – each user can have their own shopping cart object that is saved on each page!