|
 |
|
ใช้ session ป้องกันการ Copy Url แต่มันไม่ได้ครับ ทดลอง Copy เข้าได้ยาวเลยครับ |
|
 |
|
|
 |
 |
|
เห็นไปถามในกลุ่ม ได้คำตอบยังครับ
ถ้าไม่ได้ ผมข้อแก้นิดนึง เอา session_start(); ออก
จากนั้นเอา code เดิมไปวางทุกๆหน้าที่ เรียกเข้ามาถ้าไม่ได้ Login ยังไงมันก็ไม่เข้า
<?php
//session_start(); //เอาออก
if (!isset($_SESSION['UserID'])) {
echo("<script>");
echo("window.location='out.php';");
echo("</script>");
exit;
}
?>
แนะนำจากหน้าเช็คการ Login ผมประกาศตัวแปรเป็น
$_SESSION['login'] = "true";
ในทุกๆหน้าที่เรียกเมนูจากการ switch case ผมก็เอา code ไปวาง
<?php
if (!isset($_SESSION['login'])) {
echo("<script>");
echo("window.location='out.php';");
echo("</script>");
exit;
}
?>
ค่า $_SESSION['login'] ไม่ส่งมายังไงก็วิ่งไป Logout ครับ
---------------------------
ถ้ายังไม่ได้มันก็ต้องไล่จาก
1.ฟอร์มรับค่า username password
2.ไฟล์ที่ทำการเชื่อมต่อฐานข้อมูลเพื่อตรวจสอบสิทธิ์ของ user ว่ากำหนดตัวแปรไว้แบบไหน
3.อย่างน้อยก็เช็คตัวแปร โดยการ echo $_SESSION ของตัวแปรนั้นๆว่ามีมีจริง หรือ ถ้าไม่มีให้มันแสดงค่าอะไร เช่น
if (!isset($_SESSION['login'])) {
echo "เฮ้ย!! ค่า session ไม่มีมาว่ะ";
} else {
echo "เฮ้ย!! ค่า session มาแล้วนะ";
}
4.สุดท้ายถ้าตามที่แนะนำตาม คห.ที่ 2 ถ้าเอา code นั้นไปวางจริง session_start(); มันน่าจะต้องมี Error อะไรบ้างล่ะ เพราะ session_start(); มันจะชนกลับของ index.php
ตย. Error : A session had already been started - ignoring session_start() in ...
ถ้ายังไม่ใกล้เคียงก็แสดงว่า เขียน code คนละแนวทางครับ
แนวคิด มีเยอะมาก พิจารณาตามความเหมาะสมครับ
|
ประวัติการแก้ไข 2016-03-03 16:45:39 2016-03-03 16:46:51
 |
 |
 |
 |
Date :
2016-03-03 16:42:50 |
By :
apisitp |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|