Moved functin meant for api from session.php