0

この方法で cssrf 要素をフォームに追加しようとすると、私のコードは正常に機能していましたが、突然次のようになりました。

$this->addElement('hash', 'csrf', 'Category' . time());

以下のエラーが発生します

Fatal error: Cannot return string offsets by reference in /usr/share/Zend/library/Zend/Session/Abstract.php on line 160 Stack trace: 1. {main}() /Users/myname/Sites/Zend_Projects/myproject/public/index.php:0 2. Zend_Application->run() /Users/myname/Sites/Zend_Projects/myproject/public/index.php:26 3. Zend_Application_Bootstrap_Bootstrap->run() /usr/share/Zend/library/Zend/Application.php:366 4. Zend_Controller_Front->dispatch() /usr/share/Zend/library/Zend/Application/Bootstrap/Bootstrap.php:97 5. Zend_Controller_Dispatcher_Standard->dispatch() /usr/share/Zend/library/Zend/Controller/Front.php:954 6. Zend_Controller_Action->dispatch() /usr/share/Zend/library/Zend/Controller/Dispatcher/Standard.php:295 7. Effigy_MaestroController->editAction() /usr/share/Zend/library/Zend/Controller/Action.php:513 8. Zend_Form->__construct() /Users/myname/Sites/Zend_Projects/myproject/application/modules/effigy/controllers/MaestroController.php:109 9. Application_Form_Extendible_Category->init() /usr/share/Zend/library/Zend/Form.php:240 10. Zend_Form->addElement() /Users/myname/Sites/Zend_Projects/myproject/application/forms/Extendible/Category.php:100 11. Zend_Form->createElement() /usr/share/Zend/library/Zend/Form.php:1040 12. Zend_Form_Element_Hash->__construct() /usr/share/Zend/library/Zend/Form.php:1112 13. Zend_Form_Element_Hash->initCsrfValidator() /usr/share/Zend/library/Zend/Form/Element/Hash.php:83 14. Zend_Session_Namespace->__get() /usr/share/Zend/library/Zend/Session/Namespace.php:0 15. Zend_Session_Abstract::_namespaceGet() /usr/share/Zend/library/Zend/Session/Namespace.php:287

なぜこれが起こり、それに対して何ができるのでしょうか?

4

1 に答える 1

0

クイック スタートに関するコメントから、あなたもモジュールを使用して同じ問題に陥っていると思います。クイックリファレンスのためにそれを引用します。

But if you put the same same code in a module, it tries to create the session file iin the directory APPLICATION_PATH "/../data/session" which doesn't exist by default so an exception is raised.

$this->addElement('hash', 'csrf', array(
    'ignore' => true,
));

そして、このプラグインを使用できると思いますhttp://codeutopia.net/blog/2008/10/16/how-to-csrf-protect-all-your-forms/

それは何をしますか?

すべてのフォームを自動的に保護する ZF コントローラ プラグイン – いいですね。

于 2011-08-14T14:50:10.133 に答える