well a session is not really any good, as you want it to come back next visit. I would go for a cookie, created server-side. I would not use javascript as it will bloat the filesizes and generally just be a pain in the ass because people can turn of JS.
However
which they provided the first time they entered the page (where there would have been a message saying "This is your first time to this page, please enter your name..." in a seperate new window.
forgive me if I'm wrong, but it seems to me that you are asking people to enter their name <b>just</b> so that they can see their name next time they visit. I know some people are dumb, but most of us don't need you to remind us of our own names
Shops like amazon do it because if someone has an account then it is just a little <b>add-on</b> to an <b>existing feature</b>, which makes sense, but doing it just for the sake of a message is a waste of time (both yours and the visitors). I would not enter my name just because a website told me to, because it was my first visit.
What I'm saying is, if you need accounts for genuine reasons, then all you need to do is save the userid as a cookie and recall it for each page view. But if you are just doing it for the sake of a welcome message, then you are probably wasting your time, it serves no purpose and will probably annoy more people than it will entice.
To find out how to do cookies, type "set cookie" asp/php (take your pick) into google. They are really simple and you should be able to find a thousand tutorials on how cookies work and how to set/retrieve them.
CSS website design tutorials