Ever wondered how to make your own session handling functions with PHP? In this article Brian shows us how to do just that using PHP, MySQL and a bit of maths!
The code above has our login form and if it's submitted it will initialize the class and use the proper functions to start and register the values. Then the user is redirected to the welcome.php page.
Last, but surly not least, we need to create our welcome.php page:
Since this page is the first one to use our sessions with the passing key, we call the read() function to fetch the value. As seen in the read() function, we saved the value to $sess_val so where we want that data to appear we print it to the user. Then we offer a link to log out, which uses the destroy() function to kill the current session.