janggu Posted February 4, 2008 Share Posted February 4, 2008 Hi there, I created a bilingual site and connect two different language tables by two language session variables. However, when a language sesssion is created, population of data is being delayed. Basically, I have to refresh my web browser a couple of times manually in order to see the change of the language. Please see my code below and tell me if this can be fixed. Thanks very much in advance!!! // Trigger language sessions <? if (isset ($_SESSION["lang"])) { if ($_SESSION['lang'] == "en") { echo '<a href='.$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'].'&lang=fr>Francais</a>'; } else { echo '<a href='.$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'].'&lang=en>English</a>'; } } ?> // Create sessions <? session_start(); $lg = $_GET['lang']; if (!isset($_SESSION["lang"])) { $_SESSION['lang'] = "en"; if ($lg=="en") { $_SESSION['lang'] = $lg; } if ($lg=="fr") { $_SESSION['lang'] = $lg; } } else { if ($_SESSION["lang"] == "en" && $lg == "fr") { session_destroy(); $_SESSION["lang"] = $lg; } if ($_SESSION["lang"] == "fr" && $lg == "en") { session_destroy(); $_SESSION["lang"] = $lg; } } ?> // Connect two language tables by session variable <? session_start(); $conn = db_connect(); if (isset ($_SESSION["lang"])) { if ($_SESSION['lang'] == "en") { $query = "select * from tbl_page_en where qs = '$qs'"; } if ($_SESSION['lang'] == "fr") { $query = "select * from tbl_page_fr where qs = '$qs'"; } } else { $query = "select * from tbl_page_en where qs = '$qs'"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/89293-database-delay-with-session-variables/ Share on other sites More sharing options...
mikefrederick Posted February 4, 2008 Share Posted February 4, 2008 server settings? think your code is fine. with a session you shouldnt have to reload the page to see changes. Quote Link to comment https://forums.phpfreaks.com/topic/89293-database-delay-with-session-variables/#findComment-457228 Share on other sites More sharing options...
haku Posted February 4, 2008 Share Posted February 4, 2008 Try changing this code: <? if (isset ($_SESSION["lang"])) { if ($_SESSION['lang'] == "en") { echo '<a href='.$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'].'&lang=fr>Francais[/url]'; } else { echo '<a href='.$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'].'&lang=en>English[/url]'; } } ?> To this: <? if (isset ($_SESSION['lang'])) { header("Location: " . $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING'] . "&lang=" . $_SESSION['lang']); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/89293-database-delay-with-session-variables/#findComment-457243 Share on other sites More sharing options...
janggu Posted February 4, 2008 Author Share Posted February 4, 2008 Thanks for your help but it doesn't make a difference. Quote Link to comment https://forums.phpfreaks.com/topic/89293-database-delay-with-session-variables/#findComment-457261 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.