get_context_instance() is deprecated
Moodle 2.7 session management fix

The moodle session management has changed in the moodle 2.7
version. This commit applies several modifications for the
moodle 2.7 compatibility.
The lastaccess dates can be found in the moodle 2.7 USER object
so when possibile the lastaccess dates are extracted directly
from the USER object. If this is not possible then the dates
are extracted directly from the database.