Handle js format when creating a new session

New session was failing when being called from ajax requests, I added code to handle success/failure cases