Created
October 24, 2019 19:22
-
-
Save mikewing94/f9c0aaee1d3b8834024962e9aba9952d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
session_start(); | |
// Start the session | |
//header file | |
$language = $_GET['lang']; | |
$languagestart = '?lang='; | |
$newlanguage = $languagestart.$language; | |
if((isset($language)) || (!empty($language))){ | |
//new language | |
echo $newlanguage; | |
// Set session variables | |
$_SESSION["language"] = $newlanguage; | |
} | |
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; | |
echo $actual_link; | |
$a = '/?lang='; | |
if (strpos($a, $actual_link) !== false) { | |
$b = 1; //in current url | |
} else { | |
$b = 0; //not in current url | |
} | |
$new_full_link = $actual_link.$newlanguage; | |
//check if language is set but current page does not have language in URL | |
if (isset($_SESSION["language"]) && ($b == 1)){ | |
header("Location: $new_full_link"); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment