Blogger Information
Blog 31
fans 2
comment 0
visits 27671
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php如何删除和销毁Session
霏梦
Original
975 people have browsed it

-作者:霏梦

php如何删除和销毁Session

// 启动session的初始化

  1. session_start();

// 注册session的变量,给一个用户名

  1. $_SESSION["username"]='wang';

// 给下用户id

  1. $_SESSION["uid"]=1;
  2. echo $_SESSION['username'];

// 删除所有session变量

  1. $_SESSION =array();

// 判断cookie中是否存在session id

  1. if(isset($_COOKIE[session_name()]))
  2. {
  3. setcookie(session_name()," ",time()-36000,"/");
  4. }

// 测底销毁

  1. session_destroy();
Correcting teacher:天蓬老师天蓬老师

Correction status:qualified

Teacher's comments:注意错别字, 彻底销毁,还应该包括删除cookie中的session_id
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post