Split basic.php up into smaller parts

The following changes have been made in Shared/
Database functions have been moved to database.php.
Login related code has been moved to sessions.php
course-related functions have been moved to courses.php