Examples of cookie and session usage in php

WBOY
Release: 2016-07-29 09:01:06
Original
892 people have browsed it

<code><span><span><?php</span><span>//新增cookie</span>
setcookie(<span>'system'</span>,<span>'linux'</span>);
<span>//使用cookie</span><span>echo</span><span>$_COOKIE</span>[<span>'system'</span>];
<span>//销毁cookie</span>
setcookie(<span>'test'</span>, <span>''</span>, time()-<span>1</span>);
<span>//开启session</span>
session_start();
<span>//新增session</span><span>$_SESSION</span>[<span>'uname'</span>]=<span>'madao232324'</span>;
<span>//使用session</span><span>echo</span><span>'<br>'</span>.<span>$_SESSION</span>[<span>'uname'</span>];
<span>//销毁session</span><span>unset</span>(<span>$_SESSION</span>[<span>'uname'</span>]);
<span>//关闭session</span>
session_destroy();
</span></code>
Copy after login
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces the usage examples of cookies and sessions in PHP, including related content. I hope it will be helpful to friends who are interested in PHP tutorials.

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!