使用JavaScript更改Zend_Session值的最佳实践/方法

时间:2021-07-15 11:10:37

I am migrating an old project to Zend Framework. I have a drop down list that changes filter context. In the old project the onClick event of the <select> list ran a function that made a jQuery ajax call to a php script that essentially updated the $_SESSION variable and then the JavaScript reloaded the page when the response came back. I have a couple of questions:

我正在将一个旧项目迁移到Zend Framework。我有一个下拉列表,可以更改过滤器上下文。在旧项目中,

  1. Is this an okay practice?
  2. 这是一个好的做法吗?
  3. Should I send the request to a Controller instead of a servlet? One of the issues with this is that the drop down list is built in a view helper and is available across all Controllers, but I understand I could put the necessary code in and have them all inherit it.
  4. 我应该将请求发送到Controller而不是servlet吗?其中一个问题是下拉列表是在视图助手中构建的,并且可以在所有控制器中使用,但我知道我可以将必要的代码放入并让它们都继承它。
  5. If I DO go the stand-alone servlet type route, where do I put the php file in the hierarchy? I'm assuming the public folder- so pardon me if it is a dumb question.
  6. 如果我去独立的servlet类型路由,我在哪里将php文件放在层次结构中?我假设公共文件夹 - 如果这是一个愚蠢的问题,请原谅我。
  7. I'm not familiar with Zend_Session, are there any gotchas to watch out for?
  8. 我对Zend_Session不熟悉,有什么值得注意的吗?

--EDIT--
After some initial code testing I have run into an issue with my servlet php file (let's call it registrar.php) is not able to get the Zend_Session_Namespace from the Zend_Registry when it is standalone (I'm not sure if I'm not doing it right, but since it's not being sent through index.php it makes sense to me that it can't access the registry). Instead of registrar.php I'm going to create a RegistrarController

--EDIT--经过一些初步的代码测试后,我遇到了一个问题,我的servlet php文件(让我们称之为registrar.php)无法从Zend_Registry中获取Zend_Session_Namespace(如果它是独立的)(我不确定是否我做得不对,但因为它不是通过index.php发送的,所以我觉得它无法访问注册表)。而不是registrar.php我将创建一个RegistrarController

1 个解决方案

#1


0  

I have created a RegistrarController, disabled the standard layout and view and put my logic in there

我创建了一个RegistrarController,禁用了标准布局和视图,并将我的逻辑放在那里

#1


0  

I have created a RegistrarController, disabled the standard layout and view and put my logic in there

我创建了一个RegistrarController,禁用了标准布局和视图,并将我的逻辑放在那里