I am in the process of removing direct dependencies from an existing project. I have now come to removing the direct use of
$_SESSION inside scripts. This is to make the same scripts available for an environment other than a web server such as PHP CLI.
The code base I am working on consist primarily of classes, so I have thought of making a generic interface declaring common methods such as
delete($key) and so on. Any class requiring access to the session would then implement this interface, thus making testing easier (which is almost impossible at the moment).
So the questions are:
- Do you guys think this is a good approach
- Are there other ways to achieve the same abstraction
I am open to suggestions of all kind as I am also using this as a learning opportunity. If you link me to a library doing this I would prefer if you could also write a few words about why you chose it.