Moved $user (session, profile details) into global visibility, now it is fetch right before calling REST handler.
Changed session a bit.
sub validate_XXX - if parameter is invalid, it is set to default empty value (empty string or zero 0)
Forgot to assign 0 to invalid ID :)
get session - validate token only if present: don't push warning about token into "errors" - it may be unneeded
Added TODO: abstract sub for fetching entity, try memcached first, then - database.
Implement tomorrow!
Probably, then sub database_select_entity will be needed only by sub login.