denbuzze Posted March 28, 2007 Share Posted March 28, 2007 This is my current code: <?php $base = "http://www.test.com/"; $lang = strtolower(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'],0,2)); if($lang == "nl" || $lang=="de" || $lang=="en" || $lang=="fr") { header('Location:' . $base . $lang . '/index.htm'); } else { header('Location:'. $base . 'en' . '/index.htm'); } ?> It works fine, but I want to keep in mind of the usability for the users. So I have 2 questions: 1) If a user clicks on the site on e.g. "francais" (on index.htm) how do I keep a cookie to remember that the following visit, the user has to be automaticaly directed to the french section (the cookie should be 'fr'). on the site I have a link <a href="../fr/index.htm"> then the cookie should be fr 2) How do I add this (question 1) to the above code (I think with an additional if structure). It was hard to formulate this questions well, but here my complete thoughts (SEMI-CODE) If (cookie exists){ $lang_cookie = get the value of the cookie; (nl/de/en/fr) $header('Location:' . $base . $lang_cookie . '/index.htm'); } else { --- here I put the above code --- } Please don't give me any comment like 'read the entiry php manual' or 'here you have some explanation about cookies' Link to comment https://forums.phpfreaks.com/topic/44628-getting-language-from-user/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.