It can vary depending on how you travel and what country you are going to and what country you are from.
Every country has its own rules for entry, no matter whether by air, sea or land. They also have various rules depending on which country you are from.
For instance: I live in Costa Rica. If I go to Nicaragua, I will need to go inside the govt building on the Costa Rica side and get my passport stamped as “leaving the country.” Then I go to the Nicaragua side and get my passport stamped as “arriving in the country.” There are also examinations of your luggage or backpack.
When I went on a cruise and we docked at a foreign port, the cruise ship gathered up our passports and did the “arrival” thing for us.
In some countries in Europe, you can drive or take the train from country to country without any border passport check due to the Schengen agreement.
So yes, it varies.
Latest Answers