Too many things and probably in the wrong order.
Many problems do not seem to me particularly related to HTML5 in the first case.
Start with the obvious thing - you need one page (mostly a javascript application) that plays chess, so create one. If you cannot build it, then the rest essentially does not matter, if you can build (and I have no doubt that you can), then the rest is building on this possibility.
So, we get to your first question - well, the moment you load the page, you will have a session, its web page, like any other web page, so you get a session. If you are offline, you save it from the moment you were online, in any way - presumably local storage.
Do you want to move the AI to the server? So, make sure that interaction with the external interface speaks of an “interface” for recording the player’s movement and receiving AI movements. Given this separation, you can replace the AI on the ajax client (although I would expect x to be json!) It will invoke a server with the same parameters.
It gets better if you want to play player with the player, you just talk about routing through the server from one user / player to another user / player - the front-end code should not change, the server just makes ajax at the far end.
But all this, take a step back and solve problems, one at a time - if you do what you have to arrive, where you want to go without driving yourself nuts try to worry about a bucket of problems that seem scary that you probably can it’s easy to solve one at a time, and I would start running your game on my own in a browser.