You could set a cookie for their initial visit containing their original country. Then you could set a session using the same method.
Cookies have a longer lifetime and won't get erased after the user leaves the site. This allows you to pull their country after they return. Setting the session variable holds their country site data for their current visit.
Then in your code (php but expression engine plugins could do some of this) do something like this in your page header
//test to see if the session has already been set
if (isset($_SESSION['country'])) {
//redirect to http://test.$_SESSION['country'] if they are not already on that page;
} else {
//if it hasn't, test to see if the cookie is set
if (!isset($_COOKIE['country'])) {
//if not, get that information
setcookie("country", //however you get your country);
}
//Then start the new session and set country to the cookie
session_start();
$_SESSION['country'] = $_COOKIE['country'];
//then redirect based off of the session variable
}
There are several plugins that might save you from having to write this in php, like Session Variables,
Cookies,
IPGeo
With these, I am sure you can recreate that code following the same logic