如何在 Zend 中使用 cookie? [英] How to use cookies in Zend?
本文介绍了如何在 Zend 中使用 cookie?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何使用 Zend_Http_Cookie 来设置和读取 cookie?
How I use Zend_Http_Cookie to set and read cookies?
我尝试像这样设置 cookie:
I trie to set cookie like this:
$cookie = new Zend_Http_Cookie('TestCookie','TestValue','localhost.com')
但没有生成 cookie.还有我是如何用 Zend 读取 cookie 的?
$cookie = new Zend_Http_Cookie('TestCookie','TestValue','localhost.com')
but no cookie is generated. Also how I read cookies with Zend?
谢谢
推荐答案
据我所知,Zend Framework 中没有setCookie"类.只需使用普通"php:
As far as i know is there not "setCookie" Class in Zend Framework. Simply use "plain" php:
setcookie('cookieName', 'value', 'lifetime', 'path', 'domain');
要读取 cookie,您可以使用 Zend_Controller_Request_Http();
作为示例:
To read an cookie, you can use Zend_Controller_Request_Http();
as Example:
$request = new Zend_Controller_Request_Http();
$myCookie = $request->getCookie('cookieName');
这篇关于如何在 Zend 中使用 cookie?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文