php里使用session比较简单,经过session_start();启动sesssion会话功能(也能够在php 配置文件里设置 session.auto_start =1 这样就不须要调用session_start(),直接就能使用session),且该语句在脚本中必须放在全部输出语句以前(php手册中有的If you are using cookie-based sessions, you must call session_start() before anything is outputted to the browser.)。php
而后直接像使用数组同样操做$_SESSION数组便可,好比$_SESSION['something']='nothing'.便可完成设置和修改。html
至于提早销毁session,使用session_unset();函数便可销毁该会话的session记录。数组
更详细的关于php中session机制的理解参见www.cnblogs.com/acpp/archive/2011/06/10/2077592.htmlcookie