Guest User

Untitled

a guest
Jul 20th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. $valid_langs = array('en','fr','de','no');
  2. if (isset($_GET['lang'])) {
  3. // verify that it is a valid language choice before attempting to use it
  4. // you may store an array of possibilities.
  5.  
  6. if (in_array($_GET['lang'], $valid_langs)) {
  7. $language = $_GET['lang'];
  8. setcookie('lang', $_GET['lang']);
  9. }
  10. }
  11. else if (isset($_COOKIE['lang'])) {
  12.  
  13. // also be sure to check that the language is a valid choice in a cookie too.
  14. if (in_array($_GET['lang'], $valid_langs)) {
  15. $language = $_COOKIE['lang'];
  16. }
  17. }
  18.  
  19. $language = substr($_SERVER['HTTP_HOST'],0,2);
Add Comment
Please, Sign In to add comment