2016-09-26 63 views
1

我如何能在route.php访问会议笨3.0我怎么可以在笨在route.php访问会话3.0

我的应用程序是多语言的支持,所以我可以用于语言会话改变我的应用程序数据,拉布勒,静态字幕语言变化

现在我想延长我的应用程序时,语言更改时间链接

手段也变化意味着

例如

http://localhost/test/en/controller/method 

当spainsh当时URL变化变化的语言像下面

http://localhost/test/es/controller/method 

所以我怎么能做到这一点

请帮我谢谢

+0

对于这样的想法来检查codeigniter挂钩,他们可以有很大的帮助,似乎是你真正需要的东西。 – killstreet

回答

0

你总是可以访问到$_SESSION变量。但是,我不确定它是否与CodeIgniter会话库兼容。

session_start(); 

if(isset($_SESSION['lang'])) 
{ 
    // define your routing here 
} 
0

高达我理解的水平,您使用笨的会话数据作为身份指示朗及其关联的数据..?

Codeigniter使用类似使用session_start()和$ _SESSION的superglobal会话维护方式。 但建议使用而不是以使用除控制器以外的任何地方的会话数据。

试试编写一个超级控制器,它可以扩展到您的所有控制器

  class SuperController extends MY_Controller 
     { 



      public function __construct() 
      { 
       // Ensure you run parent constructor 
       parent::__construct();  
       $this->checkSess(); 
      } 

      public function checkSess() 
      { 
       //Your session check and its associated redirects 
       //eg. if $this->session->en==1 redirect to eng lang controller 



      } 

     } 

    Class YourController extends SuperController{ 
    //Your code 

} 

或者您也可以在笨Codexworld

使用multilang suppport作为或者如果你想在routes.php文件仍然使用会话。您可以像亚历山大说的那样以标准PHP方式尝试。但我怀疑它是否正常工作。