Yii cookie operation method example

WBOY
Release: 2016-07-25 08:53:02
Original
1000 people have browsed it
  1. $cookie = new CHttpCookie('mycookie','this is my cookie');
  2. $cookie->expire = time()+60*60*24*30; //Limited to 30 days
  3. Yii::app()->request->cookies['mycookie']=$cookie;
Copy code

2, read cookies:

  1. $cookie = Yii::app()->request->getCookies();
  2. echo $cookie['mycookie']->value;
Copy code

3, Destroy cookies:

  1. $cookie = Yii::app()->request->getCookies();
  2. unset($cookie[$name]);
Copy code

The above is in the yii framework The most basic cookie operation method is well encapsulated and very simple to use.



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template