当前位置: 动力学知识库 > 问答 > 编程问答 >

php - SESSION variable Not updated

问题描述:

I have A SESSION variable $_SESSION['lang'] and after the first value assigned to it it can not update with another value.

Unfortunately this works well on my localhost but not on the remote server.

/////selectlang.php file

if(empty($err)) {

session_start();

unset($_SESSION['lang']);

$_SESSION['lang'] = "";

$_SESSION['lang'] = $lang;

}

//////Calling form

if (isset($_SESSION['lang']))

{

$lang = $_SESSION['lang'];

}else

{

$lang = 'locale_en';

}

require_once ("lang/".$lang.".php");

echo '<table border="0" width="100%"><tr><td>';

echo "<font class=fontselectlanguage>".CHOOSE_LANGUAGE;

echo '<td><form action="/selectlang2" method="post">

<Select name="lang" />

<Option class="fontselectlanguage_option" value="locale_en" SELECTED>English</Option>

<Option class="fontselectlanguage_option" value="locale_vd">Vindu</Option>

</form>

Any ideas?

网友答案:

session_start(); this should be called in all cases towards top of page

so first line of your code should be

session_start();
/////selectlang.php file
if(empty($err)) {
分享给朋友:
您可能感兴趣的文章:
随机阅读: