HomePHP Using Session Handling Objects to Maintain the State of Applications with PHP Sessions
Using Session Handling Objects to Maintain the State of Applications with PHP Sessions
Here you have it. The tutorial that you were waiting for! Welcome to the concluding part of the series “Maintaining the state of applications with PHP sessions.” In several tutorials, this series goes through the key points of managing sessions in PHP, and explores some of their most advanced features, such as developing user-defined session storage modules and using session handling objects.
If you’ve already read my two previous tutorials in this series, then probably you’ve expanded your knowledge of the basics of PHP session management, including the proper understanding of some of the core operations required for creating, using and destroying sessions.
In addition, handling and propagating session IDs should be pretty familiar concepts to you, since I covered this topic in detail in the first tutorial. However, in order to get the most out of the PHP session management module, during the second article you learned how to build a custom session mechanism by utilizing the helpful “session_save_path()” and “session_set_save_handler()” functions. Specifically, the last function allows you to build an entirely customized session module. This module can potentially use MySQL (or other RDBMS) for saving session-related data, in this way increasing the security of the overall session handling mechanism.
Well, if sessions were a foreign concept to you before reading these tutorials, now you have enough source code to experiment with yourself and start including advanced session scripts within your PHP applications. Nevertheless, the subject is certainly huge and deserves an in-depth look, particularly in those topics related to advanced session handling.
Keeping this idea in mind, in this last part of the series, I’ll explain how to use the PHP built-in “session_set_save_handler()” function inside of a PHP class, in order to create highly-centralized session handling objects. Are you ready to learn how this will be done? Right, let’s go!