Zend Framework - storing and retrieving cookies
I try to put the user's email in a cookie when he logs in, and retrieve it at his next visit. The code below doesn't work, obviously I am missing something.
When user submits login info, store the email in cookie: $cookie = new Zend_Http_Cookie('emailLogin', urlencode($email), 'localhost');
At开发者_JAVA技巧 the next user's visit, retrieve the user's email: $email = $this->_request->getCookie('emailLogin');
(I had already a debate in #zftalk on why I need to store the email in cookie, I don't want to discuss that again please)
That is not what Zend_Http_Cookie is for, see php setcookie vs Zend_Http_Cookie. Try just using the native PHP setcookie method, or sessions.
精彩评论