Dealing with ‘Uncaught exception ‘Mage_Core_Exception’ with message ‘Mage registry key “_singleton/core/session” already exists”

PHP Fatal error:  Uncaught exception 'Mage_Core_Exception' with message 'Mage registry key "_singleton/core/session" already exists'

You’ll see this if you try and do

Mage::getSingleton('core/session')

from a command-line magento script which hasn’t had the session initialised already. A simple workaround is to load the session model yourself early in your script:

$session = Mage::getModel('core/session');