More refactoring - Added Task function

Session.PHP - Improved error handling
Task.PHP - new file for task functions
Added tests for empty variables

To Session.php and Study.php so it works on newer version of mysql