北京建设部网站首页,做品牌特价的网站,网站的宣传推广方式,株洲论坛有待更新。。。第23天 PHP应用后台模块SessionCookietoken身份验证唯一性演示案例后台模块-身份验证-Cookie技术后台模块-身份验证-Seession技术后台模块-数据唯一性-Token技术Cookie使用1、客户端向服务器发送HTTP请求。2、服务器检查请求头中是…有待更新。。。第23天 PHP应用后台模块SessionCookietoken身份验证唯一性演示案例后台模块-身份验证-Cookie技术后台模块-身份验证-Seession技术后台模块-数据唯一性-Token技术Cookie使用1、客户端向服务器发送HTTP请求。2、服务器检查请求头中是否包含cookie信息。3、如果请求头中包含cookie信息则服务器使用该cookie来识别客户端否则服务器 将生成一个新的cookie。4、服务器在响应头中设置cook1e信息并将其发送回客户端。5、客户端接收响应并将cookie保存在本地。6、当客户端发送下一次HTTP请求时它会将cookie信息附加到请求头中。7、服务器收到请求并检查cookie的有效性。8、如果cookie有效则服务器响应请求。否则服务器可能会要求客户端重新登录测试代码admin-c.php!DOCTYPE html html langzh-CN head meta charsetUTF-8 title后台管理系统 - 登录/title style * { margin: 0; padding: 0; box-sizing: border-box; font-family: Microsoft YaHei, Arial, sans-serif; } body { height: 100vh; background: linear-gradient(135deg, #2c3e50, #3498db); display: flex; justify-content: center; align-items: center; } .login-box { width: 360px; background: #fff; padding: 40px 30px; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,0.2); } .login-box h2 { text-align: center; margin-bottom: 30px; color: #333; } .login-box input { width: 100%; height: 42px; margin-bottom: 20px; padding-left: 12px; border: 1px solid #ddd; border-radius: 4px; font-size: 14px; } .login-box input:focus { outline: none; border-color: #3498db; } .login-box button { width: 100%; height: 42px; background: #3498db; border: none; color: #fff; font-size: 16px; border-radius: 4px; cursor: pointer; } .login-box button:hover { background: #2980b9; } .login-footer { text-align: center; margin-top: 15px; font-size: 12px; color: #999; } /style /head body div classlogin-box h2后台管理系统/h2 form action methodpost input typetext nameusername placeholder用户名 required input typepassword namepassword placeholder密码 required button typesubmit登录/button /form div classlogin-footer © 2025 管理系统 /div /div /body /html ?php //登录文件 include ../config.php; $user$_POST[username]; $password$_POST[password]; //连接数据库进行查询 $sqlselect * from admin where username$user and password$password;; echo br; //echo $sql; $datamysqli_query($con,$sql); if($_SERVER[REQUEST_METHOD]POST) { //是否登陆成功 if(mysqli_num_rows($data)0) { //成功登录才有cookie $expire time()60*60*24*30 ;//一个月后过期 setcookie(username,$user,$expire,/); setcookie(password,$password,$expire,/); // echo scriptalert(登陆成功);/script; header(location:index-c.php); }else{ echo scriptalert(fail);/script; } }index-c.php?php if($_COOKIE[username]admin and $_COOKIE[password]123456) { } else { header(location:admin-c.php); } ? !DOCTYPE html html langzh-CN head meta charsetUTF-8 meta nameviewport contentwidthdevice-width, initial-scale1.0 title后台管理系统/title style body { font-family: Arial, sans-serif; margin: 0; padding: 20px; background-color: #f4f4f4; } .header { background-color: #2c3e50; color: white; padding: 15px; text-align: center; border-radius: 5px; margin-bottom: 20px; } .logout-btn { background-color: #e74c3c; color: white; border: none; padding: 8px 16px; border-radius: 3px; cursor: pointer; float: right; margin-top: -35px; } .logout-btn:hover { background-color: #c0392b; } .content { background-color: white; padding: 20px; border-radius: 5px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); } .welcome { margin-bottom: 20px; } /style /head body div classheader h1后台首页/h1 a hreflogout-c.php退出登录/a div styleclear: both;/div /div div classcontent div classwelcome h2欢迎使用后台管理系统/h2 p当前登录用户?php echo $_COOKIE[username]?/p p登录时间span idlogin-time/span/p /div div h3系统状态/h3 ul li用户总数128/li li今日访问量245/li li系统运行正常/li /ul /div /div script // 显示当前时间 document.getElementById(login-time).textContent new Date().toLocaleString(); // 退出登录功能 function logout() { if(confirm(确定要退出登录吗)) { alert(退出登录成功正在跳转到登录页面...); // 在实际应用中这里应该跳转到登录页面 // window.location.href login.html; } } /script /body /html ?php //登陆成功的首页文件logout-c.php?php //退出登录 //1.设置cookie为空让之前的if语句为假达到无法登录的效果 //2.也可以调用删除函数 setcookie(username,,time()-3600,/); setcookie(password,,time()-3600,/); header(location:admin-c.php); exit();