setcookie在域内

时间:2015-03-10 18:47:18

标签: php cookies set

我已经忍受了大约2天的setcookie,如果你可以帮助我,谢谢! 我的问题是这是设置settings.php文件中包含的语言的一部分,它看起来像这样......

$language = "english";

    if(!isset($_COOKIE["language"]))
        setcookie("language", "english", time()+(60*60*24*365));
    else
        $language = $_COOKIE["language"];

    if($_GET['language']=="english" || $_GET['language']=="serbian"){
        setcookie("language", $_GET['language'], time()+(60*60*24*365));
        $language =  $_GET['language'];
    }

    if($language == "english")
    {
        include("template/language/english.php");
    }
    else if($language == "serbian")
    {
        include("template/language/serbian.php");
    }

当我使用它时,只是让我使用的语言是我选择语言的文件夹而不是其他文件,如果您可以帮助我在一个文件夹中更改语言以更改此网站上的所有文件夹

1 个答案:

答案 0 :(得分:1)

试试这个

  setcookie("language", $_GET['language'], time()+(60*60*24*365),"/");

$language = "english";

    if(!isset($_COOKIE["language"]))
      {  setcookie("language", "english", time()+(60*60*24*365),"/");}
    else
      {  $language = $_COOKIE["language"];}

    if     ($_GET['language']=="english" || $_GET['language']=="serbian"){
        setcookie("language", $_GET['language'], time()+(60*60*24*365),"/");}
        $language =  $_GET['language'];


    if($language == "english")
    {
        include("template/language/english.php");
    }
    else if($language == "serbian")
    {
        include("template/language/serbian.php");
    }