Using an object
on multiple 'scripts':
First, you have to decide what kind of structure your OOP application has.
If you use something like MVC
pattern, you do not have to this by using SESSION or REQUEST, because you can 'plug' the objects you want to use into 'one'.
What does this mean?
A quick example:
- User A enters your site index.php
- Now you can load the content from a static index.html,
but if you want to check whether the user is authenticated to see specific contents e.g. the 'Admin Login', you can use
include_once('Authentication.php')
and initiate a class from this file, e.g. <?php $Auth = new Auth_Handler; ?>
This will make the Auth class also available in the index.php or any other file you want to include this class.
If you want to pass the authentication class' return value to another file e.g. 'register.php' you can use the SESSION or any other Cache.
Passing whole objects is not recommend due to their size.
Including and initiating the wanted classes at the beginning of files is much better.
And passing the returns by SESSION uses less space.
It really depends one which framework or API you want to use, or what project you want to create.
Edited: Here you can see how i mean 'plug into one' "Link to a explaining picture ;)"