Home >Backend Development >PHP Tutorial >Examples of cookie and session usage in php
<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.