When migrating solutions from and script from SharePoint 2010 to 2013, we ran into some weird error where we could not fetch the current logged in user with “_spUserId” anymore.
var user = _spUserId
As a workaround we used below;
var user = currentWeb.get_currentUser();