PHP DevCenter
oreilly.comSafari Books Online.Conferences.

advertisement


Session Tracking: Part 2
Pages: 1, 2, 3

Once I've defined these functions, I can then include the library within another script and call the session_set_save_handler() function, which acts to tie the MySQL functions into PHP's session-handling functionality. Listing 3 is a script showing you how this function is used to integrate the MySQL functions.


Listing 3: Using session_set_save_handler() to integrate the MySQL functions



<?
INCLUDE("mysql_sessions.inc");

session_set_save_handler("mysql_session_open", "mysql_session_close",
  "mysql_session_select", "mysql_session_write",
  "mysql_session_destroy",
  "mysql_session_garbage_collect");

session_start();

// At this point, sessions can be used just as they were in the
// previous article!

?>


Conclusion

This wraps up this week's article, and also the conclusion of the two-part series on session tracking. The first article demonstrated how sessions can provide an invaluable addition to your Internet application, allowing for data to transparently follow a user. This article built upon what was learned in the first article, showing how it's possible to quickly create your own interface to the session functionality, making it possible to handle data via any PHP-supported media.

Next week, I turn my attention toward PHP's encryption capabilities, showing you how PHP's vast functionality can be used in collaboration with several of the most advanced encryption algorithms in the world.

W.J. Gilmore has been developing PHP applications since 1997, and is frequently published on the subject within some of the Web's most popular development sites. He is the author of 'A Programmer's Introduction to PHP 4.0' (January 2001, Apress), and is the Assistant Editorial Director of Web and Open Source Technologies at Apress.


Return to the PHP DevCenter.




Valuable Online Certification Training

Online Certification for Your Career
Earn a Certificate for Professional Development from the University of Illinois Office of Continuing Education upon completion of each online certificate program.

PHP/SQL Programming Certificate — The PHP/SQL Programming Certificate series is comprised of four courses covering beginning to advanced PHP programming, beginning to advanced database programming using the SQL language, database theory, and integrated Web 2.0 programming using PHP and SQL on the Unix/Linux mySQL platform.

Enroll today!


Sponsored by: