"Set session data"<?PHPSession_Start();//the initialization of the//session file can be saved Dobule,integer,bool,array,object$_session[' Name ']= ' Lisa ';$_session[' Age ']=100;$_session[' Isboy ']=true;$arr 1=Array("Beijing", "Lisa", "183249123");$_session[' Arr1 ']=$arr 1;$dog 1=NewDog ("Xiao Huang", 5, "yellow");//introducing the Dog class$_session[' Dog1 ']=$dog 1;?>"Get Session Data"<?PHPSession_Start();//InitializePrint_r($_session);//all Session$_session[' Key '];//specify a value with key get$arr 1=$_session[' arr ']//Get Arrayforeach($arr 1 as $key=$val){ Echo"$val";}//gets the object, to introduce the object class dog.class.php$dogs=$_session[' Dog1 ']; $dogs->getname ();//class Method?>"Update session data"<?PHPSession_Start();//Initialize$_session[' Name ']= ' newname ';?>"Delete session data"<?PHPSession_Start();//Initializeunset($_session[' key ']);//Delete a keySession_destroy();//Delete all keys, corresponding session files deleted?>
Operation of the PHP session