Unfortunately, this probably won't be as simple to fix as felgall makes it out to sound.

Think more of a Cartesian plane. I have positions of x,y coordinates, but in our situation I can only move through adjacent cells, which I'll call neighbors. Fortunately, figuring out neighbors if very easy to do if we assume that each step is equivalent to 1.

So lets say I start at 0,0. I move right one step to 1,0. That is 'B'. Then I move up by one to 1,1 (c), up one to 1,2(d), right one to 2,2(e). Now I have to determine if I can go back to 1,0.

In position 2,2 I have at most four neighbors, assuming I can only move in 90 degree angles. So my options are (3,2), (2,1), (2,3), and (1,2). So all I have to do is determine if I can go to cell with the coordinates of 1,0 (which is B), and I can see that (1,0) would not pass the check as being a valid neighbor.

My approach is more of a data driven approach. I'd have a single 'page' which controls it all. Sessions would store current locations (2,2 for e), and querystring would determine desired location (1,0). Check if 1,0 is valid move from session, and if so execute whatever code is required and update the session to store the new coordinates.

**Edit:**

Also, this will prevent the use of direct typing or holding the window open. On a side note, persisting storage will end up being a requirement; if they terminate the session for any reason than you'll lose their location. Sessions are quick and easy to work with, but they are not persistent, so you may be needing to update coordinates within a database on each move.