session
session_start(); //开始使用session $_SESSION[‘test‘] = time(); //设置一个session echo "session_id:".session_id(); //显示当前的session_id echo "<br>"; echo $_SESSION[‘test‘]; //输出session值 unset($_SESSION[‘test‘]); //销毁一个session echo "<br>"; var_dump($_SESSION); //session_id:lpd56n5qsmga006v3ss300sgf4 //1518599397 //array(0) { //}
cookie
setcookie(‘test‘, ‘1‘, 0, ‘/‘); //name, value, expire, path echo $_COOKIE[‘test‘]; //1 setcookie(‘test‘, ‘‘, time()-1) //删除cookie(删除test的cookie值)