session //将用户的会话数据存储在服务端,通过 session_start()开启session,通过$_SESSION读写session
session_start(); //开启session$_SESSION['test'] = time(); //通过全局变量$_SESSION,写入一个sessionecho "session_id:".session_id(); //显示当前的session_idecho "";echo $_SESSION['test']; //通过全局变量$_SESSION,读取一个sessionunset($_SESSION['test']); //销毁一个sessionecho "";var_dump($_SESSION);//session_id:lpd56n5qsmga006v3ss300sgf4//1518599397//array(0) {//}
cookie //将数据存储在客户端
setcookie('test', '1', 0, '/'); //name, value, expire, pathecho $_COOKIE['test'];//1setcookie('test', '', time()-1) //删除cookie(删除test的cookie值)