2011-05-24 88 views
0

我在zend框架中使用会话。它是不同的默认会话命名空间中的'默认'和'默认'?

问题是我需要知道的是就在我的应用程序

new Zend_Session_Namespace("default"); 

new Zend_Session_Namespace("Default"); 

之间的差异,我都用了,好像代码不能正常工作, 如果有差异,那么使用什么是正确的。

这里是我的代码

<?php 
class Admin_DashboardController extends Zend_Controller_Action 
{ 
    function init() 
    { 
     // 
    } 


    /** 
    * Add hotelId to default session 
    * redirect to admin/hotels if hotelId is not avialble 
    */ 
    public function indexAction() 
    {  
     $params = $this->getRequest()->getParams(); 
     $hotelid = NULL; 

      $config_session = new Zend_Session_Namespace("default"); 
      $config_session->hotelid = $params['id']; 

     if(isset($params['id']) && !empty($params['id'])){ 

     }else{ 

      //redirect user to select hotels page 
      $redirector = new Zend_Controller_Action_Helper_Redirector(); 

      $url = array(
       'action' => 'admin/hotels/index' 
      ); 

      $redirector->gotoRouteAndExit($url); 

     }     
    } 
} 

回答

2

所有Zend_Session_Namespace确实在内部是创建$_SESSION超全局内部命名的数组。由于PHP中的数组键区分大小写,因此“Default”和“default”将被视为单独的名称空间。

如果您希望使用相同的数据,您可以使用您想要的任何一个,只需保持一致。

+0

邑,我undestand,谢谢............... – 2011-05-24 06:37:31