Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use cookies in Zend?

How I use Zend_Http_Cookie to set and read cookies?

I trie to set cookie like this:

$cookie = new Zend_Http_Cookie('TestCookie','TestValue','localhost.com') but no cookie is generated. Also how I read cookies with Zend?

Thanks

like image 518
user594791 Avatar asked May 11 '11 08:05

user594791


People also ask

How are cookies sent in Http?

The Set-Cookie header is sent by the server in response to an HTTP request, which is used to create a cookie on the user's system. The Cookie header is included by the client application with an HTTP request sent to a server, if there is a cookie that has a matching domain and path.

What is Zend Cache?

Zend_Cache provides a generic way to cache any data. Caching in Zend Framework is operated by frontends while cache records are stored through backend adapters ( File , Sqlite , Memcache ...) through a flexible system of IDs and tags.

What is the use of Zend framework in PHP?

Zend Framework is a collection of professional PHP packages with more than 570 million installations. It can be used to develop web applications and services using PHP 5.6+, and provides 100% object-oriented code using a broad spectrum of language features.


1 Answers

As far as i know is there not "setCookie" Class in Zend Framework. Simply use "plain" php:

setcookie('cookieName', 'value', 'lifetime', 'path', 'domain');

To read an cookie, you can use Zend_Controller_Request_Http(); as Example:

  $request = new Zend_Controller_Request_Http();
  $myCookie = $request->getCookie('cookieName');
like image 133
opHASnoNAME Avatar answered Sep 24 '22 09:09

opHASnoNAME