|
 |
|
ใส่ session_destroy() แต่ยังกดปุ่ม Back กลับไปหน้า Home ได้ |
|
 |
|
|
 |
 |
|
กดปุ่ม back มันน่าจะเป็นแคทของเบราเซอร์ มันถึงยังเข้าหน้า home ได้
เมื่อ logout แล้ว จากนั้นกดปุ่ม back ไปหน้า home แล้วกดปุ่ม F5 อีกที ดูว่ามัน logout จริงหรือไม่ ถ้ายังใช้งานได้ปกติ แสดงว่าโค้ดมีปัญหาครับ
ปล. หน้า check login ไม่มีความปลอดภัยเลยนะครับ
|
 |
 |
 |
 |
Date :
2014-06-23 17:10:12 |
By :
arm8957 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คุณ arm8957 คะ
เป็นอย่างที่คุณบอกเลยค่ะ คือกดปุ่ม back ไปหน้า home แล้วกดปุ่ม F5 มันก็ยังไม่ logout เลยค่ะ T^T
เรื่องของความปลอดภัยยังไม่วอรี่เท่าไรค่ะ เพราะตอนนี้แค่ล็อกอินล้อกเอาท์ยังทำไม่ได้ดีเลย
คือเพิ่งเคยมาเขียน PHP ค่ะ ก็เลยยังไม่ค่อยรู้เรื่องเท่าไร คงต้องค่อยๆศึกษาไปค่ะ ขอบคุณค่ะ
Edit :: เพิ่มโค้ดหน้า Home ที่จะลิงค์มาหลังจากล็อกอินสำเร็จค่ะ (ตอนนี้ตัดเรื่องล็อกเอาท์ไปก่อนแล้วกันค่ะ T..T)
คือเราก็เพิ่มให้มันเช็ค session ก่อน แต่ติดใจอยู่นิดหนึ่งว่าตรงบรรทัดที่สาม if($_SESSION['CustomerID'] = "")
ถ้าเราเขียนว่า if($_SESSION['CustomerID'] = "") มันจะลิงค์มาได้หลังจากล็อกอินนะคะ
แต่ถ้าเราเขียนว่า if($_SESSION['CustomerID'] == "") มันจะไม่ลิงค์มา
เราสงสัยว่า = กับ == คือตามหลักการแล้ว == มันน่าจะถูกต้องกว่าไม่ใช่หรอคะ แต่ทำไมมันจึงไม่ลิงค์มา
Code (PHP)
<?php
session_start();
if($_SESSION['CustomerID'] = "")
{
//if(!isset($_SESSION["CustomerID"])){
header("Location:login.php");
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>IMS :: Inventory Management System</title>
<link href="Site.css" rel="stylesheet">
</head>
<body>
<?php include("header.php"); ?>
<div id="main">
<h1>Welcome to Inventory Management System</h1>
</div>
</body>
</html>
|
ประวัติการแก้ไข 2014-06-24 08:28:40
 |
 |
 |
 |
Date :
2014-06-24 08:28:10 |
By :
Branchest |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
03.if($_SESSION['CustomerID'] = "")
ก๊อบมาหรือพิมพ์ใหม่มันต้องเป็น
03.if($_SESSION['CustomerID'] == "") // "=" สองตัว
และควรใช้แบบนี้ครับ
03.if(isset($_SESSION['CustomerID']) || $_SESSION['CustomerID'] == "")
|
 |
 |
 |
 |
Date :
2014-06-24 08:41:00 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|