1.案例:设置session
<?php header('content-type:text/html;charset=utf-8'); //开启会话 session_start(); //设置数据 $_SESSION['username'] ='king'; $_SESSION['email'] = '721812901@qq.com'; $_SESSION['age'] = 23; echo 'sessiond的名字:',session_name(),'<br/>'; echo 'sessiond的id:',session_id(),'<br/>';
2.
<?php session_start(); //将$_SESSION 数据清空 $_SESSION=[]; //删除会话cookie if(ini_get('session.use_cookies')){ $params = session_get_cookie_params(); setcookie(session_name(),'',time()-1,$params['path'],$params['domain'],$params['secure'],$params['httponly']); } //销毁会话 session_destroy();