Home >Backend Development >PHP Tutorial >PHP cookies
Session technology
cookie
A technology that allows server-side scripts to store data in the browser,
Allows the server to send instructions to the browser to manage cookie data stored on the browser side
If the browser stores cookie data stored by a server, it will bring the cookie data when making requests
<code><span>//增、改</span><span>setcookie(key,val)</span>; <span>//删</span><span>setcookie(key,<span>''</span>)</span>; <span>//获取浏览器携带的cookie数据</span> $_COOKIE<span>[key]</span></code>
Features:
Validity period:
The default is a temporary cookie, also called a session cookie. The session ends (the browser is closed ) to clear. The lifetime can be determined by setting the timestamp (from the first second in 1970), and the browser time uses Greenwich Mean Time (GMT) as the standard
<code><span>setcookie(key,val,<span>time()</span>+<span>60</span>)</span>; <span>//代表保存1分钟,浏览器会检查是否失效</span><span>setcookie(key,val,<span>0</span>)</span>; <span>//默认会话</span><span>setcookie(key,<span>''</span>,<span>time()</span>-<span>1</span>)</span>; <span>//删除cookie</span><span>setcookie(key,val,PHP_INT_MAX)</span>; <span>//逻辑上表示永久有效</span></code>
<code> setcookie(<span>key</span>,val,<span>0</span>,<span>'/');</span></code>
<code> me.com <span>//一级域名</span> lig.me.com <span>//二级域名</span> bee.me.com <span>//二级域名</span> setcookie(key,<span>val</span>,<span>0</span>,<span>''</span>,<span>'me.com'</span>);</code>
<code> setcookie(key,<span>val</span>,<span>0</span>,<span>''</span>,<span>''</span>,<span>true</span>);</code>
<code> setcookie(key,<span>val</span>,<span>0</span>,<span>''</span>,<span>''</span>,<span>false</span>,<span>true</span>);</code>').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });
The above is an introduction to cookies in PHP, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.