Home >Backend Development >PHP Tutorial >Examples of cookie and session usage in php

Examples of cookie and session usage in php

WBOY
WBOYOriginal
2016-07-29 09:01:06939browse

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

Statement:
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