简体   繁体   中英

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 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM