我有一个登录系统。然后,用户进行了登录,他可以访问私人资料(个人数据)。
我需要知道用户登录什么来获取他的东西。所以,我需要这样的东西:$nameUser=$_SESSION['u_name']
正确吗?那么我可以这样做的查询:
Select photo*from tablePhotos where name= $nameUser
。
我拥有的代码是否被占用,或者它有安全问题? 它表示为每个会话生成一个session_id?有意义吗?什么是“规则”?
我对会话没有多少经验......
<?php
session_start();
if(empty($_SESSION['u_name']))
header("Location:index.php");
if(isset($_GET['logout'])) {
session_destroy();
header("Location:emprego.php");
}
$name = $_SESSION['u_name'];
echo $name ;
echo "<a href='secure.php?logout'><b>Logout<b></a>";
?>
答案 0 :(得分:1)
只要您始终清理数据并使用
等查询"Select * from tablePhotos where name= '" . mysql_real_escape_string($nameUser) . "'"
一切都很好