Heim > Artikel > Backend-Entwicklung > php中cookie和session使用范例
<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></span></code>').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });
以上就介绍了php中cookie和session使用范例,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。