While migrating solutions and scripts from SP2010 to SP2013 “_spUserId” doesn’t work

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();

Related Article: