* Thus wrote Webmaster ([EMAIL PROTECTED]): > Hi, > > I am just starting to understand how the session handling routines work in > php. > I can pass objects to other scripts. So I can put the language into the > object that the visitor chose at the very first page. > But what if a visitor bookmarked my homepage and comes back after a few > weeks. > How can I guarantee that a language is always choosen? I mean how is this > done professionally? > What do I have to write at the beginning of every page? > > I hope it is clear what I am asking.
You should check the 'Accept-Language' header [1] that the client usually sends: $languages = $_SERVER['HTTP_ACCEPT_LANGUAGE']; you'll have a string like: en;q=1.0, de;q=0.9, da;q=0.1 meaning that the user prefers english but if you don't have an english translation, give me german, and last but not least, I can read danish a bit. If the client doesn't have the header then direct them to a page that has them select their language choice. Then handle their choice with session data [2]. I would have the session data override the Accept-language header so that the user can manually override his browser settings. You can see how google [3] does things by modifying your language settings in your browser and your personal google settings. IMO they have a very nice language detection system. [1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4 [2] http://php.net/session [3] http://www.google.com/ Curt -- "I used to think I was indecisive, but now I'm not so sure." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php