It seems to me that you have the links duplicated on each page and each link goes to a different page.
So if you picked a link that has no value then $state and $city become empty.
Or maybe you have this setup on one page only and each link displays different content.
And when a link has no value then the values in $state and $city are lost.
But I could guess all night on how your program is set up.
Either way, to solve your problem, using sessions would work very well.