js will handle errors and if successful save session id in localStorage