Invalid state (error 500) after PHP/SDK redirect