首页 > 代码库 > thinkphp-session与cookie
thinkphp-session与cookie
Session
class SessionController extends Controller {
public function index(){
//session(‘name‘,‘yjh‘); //session赋值
//session(‘name‘,null); //删除name值
//session(null); //删除所有的值
//session(‘[pause]‘); //暂停写入
//session(‘[start]‘); //开启写入
//session(‘[destroy]‘); //销毁最新的session
//session(‘[regenerate]‘); //重新生成session id
}
public function test(){
//echo session(‘name‘); //获取session值
//session(‘?name‘); //判断session是否存在
}
}
2.cookie
class CookieController extends Controller {
public function index(){
//cookie(‘name‘,‘123‘); //cookie赋值
//cookie(‘name‘,‘123‘,3600); //cookie过期时间
//过期时间 设置前缀
//cookie(‘name‘,‘123‘array(‘expire‘=>3600,‘prefix‘=>‘think_‘));
//cookie(‘name‘,null); //删除name
//cookie(null); //删除所有
//cookie(null,‘think_‘); //删除指定前缀的
}
public function test(){
//echo cookie(‘name‘); //取name的值
//echo cookie(‘think_name‘); //取指定前缀的值
}
}
thinkphp-session与cookie